using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using C1.Win.C1Input;
using C1.Win.C1List;
using C1.Win.C1TrueDBGrid;
using PCSComProduction.DCP.BO;
using PCSComProduction.DCP.DS;
using PCSComUtils.Common;
using PCSComUtils.Common.BO;
using PCSComUtils.PCSExc;
using PCSUtils.Log;
using PCSUtils.Utils;
using AddNewModeEnum = C1.Win.C1TrueDBGrid.AddNewModeEnum;
using CancelEventArgs = System.ComponentModel.CancelEventArgs;
using ColEventArgs = C1.Win.C1TrueDBGrid.ColEventArgs;

namespace PCSProduction.DCP
{
	/// <summary>
	/// Summary description for ManualProductionPlanning.
	/// </summary>
	public class ManualProductionPlanning : Form
	{
		private TextBox txtProductionLine;
		private Label lblProductionLine;
		private Button btnProductionLine;
		private C1Combo cboCCN;
		private Button btnCycleSearch;
		private TextBox txtCycle;
		private Label lblCycle;
		private Label lblCCN;
		private C1TrueDBGrid dgrdData;
		private Button btnSave;
		private Button btnClose;
		private Button btnHelp;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private Container components = null;

		public const string THIS = "PCSProduction.DCP.ManualProductionPlanning";
		private DataTable dtbGridLayOut;
		private int intCCNID = 0;
		private Button btnGenerate;
		private Button btnSearch;
		private C1DateEdit dtmDate; 
		private DataSet dstData;
		private Button btnCutOver;
		private Button btnIgnore;
		DataTable dtbProductInfo;
		DataTable dtbIgnoreList = new DataTable();
		Thread thrProcess = null;
		private System.Windows.Forms.Button btnCalculateTime;
		DataTable dtbBeginStock = new DataTable();

		public ManualProductionPlanning()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(ManualProductionPlanning));
			this.txtProductionLine = new System.Windows.Forms.TextBox();
			this.lblProductionLine = new System.Windows.Forms.Label();
			this.btnProductionLine = new System.Windows.Forms.Button();
			this.cboCCN = new C1.Win.C1List.C1Combo();
			this.btnCycleSearch = new System.Windows.Forms.Button();
			this.txtCycle = new System.Windows.Forms.TextBox();
			this.lblCycle = new System.Windows.Forms.Label();
			this.lblCCN = new System.Windows.Forms.Label();
			this.dgrdData = new C1.Win.C1TrueDBGrid.C1TrueDBGrid();
			this.btnSave = new System.Windows.Forms.Button();
			this.btnClose = new System.Windows.Forms.Button();
			this.btnHelp = new System.Windows.Forms.Button();
			this.btnGenerate = new System.Windows.Forms.Button();
			this.btnSearch = new System.Windows.Forms.Button();
			this.dtmDate = new C1.Win.C1Input.C1DateEdit();
			this.btnCutOver = new System.Windows.Forms.Button();
			this.btnIgnore = new System.Windows.Forms.Button();
			this.btnCalculateTime = new System.Windows.Forms.Button();
			((System.ComponentModel.ISupportInitialize)(this.cboCCN)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.dgrdData)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.dtmDate)).BeginInit();
			this.SuspendLayout();
			// 
			// txtProductionLine
			// 
			this.txtProductionLine.AccessibleDescription = resources.GetString("txtProductionLine.AccessibleDescription");
			this.txtProductionLine.AccessibleName = resources.GetString("txtProductionLine.AccessibleName");
			this.txtProductionLine.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("txtProductionLine.Anchor")));
			this.txtProductionLine.AutoSize = ((bool)(resources.GetObject("txtProductionLine.AutoSize")));
			this.txtProductionLine.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("txtProductionLine.BackgroundImage")));
			this.txtProductionLine.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("txtProductionLine.Dock")));
			this.txtProductionLine.Enabled = ((bool)(resources.GetObject("txtProductionLine.Enabled")));
			this.txtProductionLine.Font = ((System.Drawing.Font)(resources.GetObject("txtProductionLine.Font")));
			this.txtProductionLine.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("txtProductionLine.ImeMode")));
			this.txtProductionLine.Location = ((System.Drawing.Point)(resources.GetObject("txtProductionLine.Location")));
			this.txtProductionLine.MaxLength = ((int)(resources.GetObject("txtProductionLine.MaxLength")));
			this.txtProductionLine.Multiline = ((bool)(resources.GetObject("txtProductionLine.Multiline")));
			this.txtProductionLine.Name = "txtProductionLine";
			this.txtProductionLine.PasswordChar = ((char)(resources.GetObject("txtProductionLine.PasswordChar")));
			this.txtProductionLine.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("txtProductionLine.RightToLeft")));
			this.txtProductionLine.ScrollBars = ((System.Windows.Forms.ScrollBars)(resources.GetObject("txtProductionLine.ScrollBars")));
			this.txtProductionLine.Size = ((System.Drawing.Size)(resources.GetObject("txtProductionLine.Size")));
			this.txtProductionLine.TabIndex = ((int)(resources.GetObject("txtProductionLine.TabIndex")));
			this.txtProductionLine.Text = resources.GetString("txtProductionLine.Text");
			this.txtProductionLine.TextAlign = ((System.Windows.Forms.HorizontalAlignment)(resources.GetObject("txtProductionLine.TextAlign")));
			this.txtProductionLine.Visible = ((bool)(resources.GetObject("txtProductionLine.Visible")));
			this.txtProductionLine.WordWrap = ((bool)(resources.GetObject("txtProductionLine.WordWrap")));
			this.txtProductionLine.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtProductionLine_KeyDown);
			this.txtProductionLine.Validating += new System.ComponentModel.CancelEventHandler(this.txtProductionLine_Validating);
			// 
			// lblProductionLine
			// 
			this.lblProductionLine.AccessibleDescription = resources.GetString("lblProductionLine.AccessibleDescription");
			this.lblProductionLine.AccessibleName = resources.GetString("lblProductionLine.AccessibleName");
			this.lblProductionLine.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("lblProductionLine.Anchor")));
			this.lblProductionLine.AutoSize = ((bool)(resources.GetObject("lblProductionLine.AutoSize")));
			this.lblProductionLine.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("lblProductionLine.Dock")));
			this.lblProductionLine.Enabled = ((bool)(resources.GetObject("lblProductionLine.Enabled")));
			this.lblProductionLine.Font = ((System.Drawing.Font)(resources.GetObject("lblProductionLine.Font")));
			this.lblProductionLine.ForeColor = System.Drawing.Color.Maroon;
			this.lblProductionLine.Image = ((System.Drawing.Image)(resources.GetObject("lblProductionLine.Image")));
			this.lblProductionLine.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("lblProductionLine.ImageAlign")));
			this.lblProductionLine.ImageIndex = ((int)(resources.GetObject("lblProductionLine.ImageIndex")));
			this.lblProductionLine.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("lblProductionLine.ImeMode")));
			this.lblProductionLine.Location = ((System.Drawing.Point)(resources.GetObject("lblProductionLine.Location")));
			this.lblProductionLine.Name = "lblProductionLine";
			this.lblProductionLine.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("lblProductionLine.RightToLeft")));
			this.lblProductionLine.Size = ((System.Drawing.Size)(resources.GetObject("lblProductionLine.Size")));
			this.lblProductionLine.TabIndex = ((int)(resources.GetObject("lblProductionLine.TabIndex")));
			this.lblProductionLine.Text = resources.GetString("lblProductionLine.Text");
			this.lblProductionLine.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("lblProductionLine.TextAlign")));
			this.lblProductionLine.Visible = ((bool)(resources.GetObject("lblProductionLine.Visible")));
			// 
			// btnProductionLine
			// 
			this.btnProductionLine.AccessibleDescription = resources.GetString("btnProductionLine.AccessibleDescription");
			this.btnProductionLine.AccessibleName = resources.GetString("btnProductionLine.AccessibleName");
			this.btnProductionLine.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("btnProductionLine.Anchor")));
			this.btnProductionLine.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnProductionLine.BackgroundImage")));
			this.btnProductionLine.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("btnProductionLine.Dock")));
			this.btnProductionLine.Enabled = ((bool)(resources.GetObject("btnProductionLine.Enabled")));
			this.btnProductionLine.FlatStyle = ((System.Windows.Forms.FlatStyle)(resources.GetObject("btnProductionLine.FlatStyle")));
			this.btnProductionLine.Font = ((System.Drawing.Font)(resources.GetObject("btnProductionLine.Font")));
			this.btnProductionLine.Image = ((System.Drawing.Image)(resources.GetObject("btnProductionLine.Image")));
			this.btnProductionLine.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnProductionLine.ImageAlign")));
			this.btnProductionLine.ImageIndex = ((int)(resources.GetObject("btnProductionLine.ImageIndex")));
			this.btnProductionLine.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("btnProductionLine.ImeMode")));
			this.btnProductionLine.Location = ((System.Drawing.Point)(resources.GetObject("btnProductionLine.Location")));
			this.btnProductionLine.Name = "btnProductionLine";
			this.btnProductionLine.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("btnProductionLine.RightToLeft")));
			this.btnProductionLine.Size = ((System.Drawing.Size)(resources.GetObject("btnProductionLine.Size")));
			this.btnProductionLine.TabIndex = ((int)(resources.GetObject("btnProductionLine.TabIndex")));
			this.btnProductionLine.Text = resources.GetString("btnProductionLine.Text");
			this.btnProductionLine.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnProductionLine.TextAlign")));
			this.btnProductionLine.Visible = ((bool)(resources.GetObject("btnProductionLine.Visible")));
			this.btnProductionLine.Click += new System.EventHandler(this.btnProductionLine_Click);
			// 
			// cboCCN
			// 
			this.cboCCN.AccessibleDescription = resources.GetString("cboCCN.AccessibleDescription");
			this.cboCCN.AccessibleName = resources.GetString("cboCCN.AccessibleName");
			this.cboCCN.AddItemSeparator = ';';
			this.cboCCN.AllowRowSizing = C1.Win.C1List.RowSizingEnum.AllRows;
			this.cboCCN.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("cboCCN.Anchor")));
			this.cboCCN.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("cboCCN.BackgroundImage")));
			this.cboCCN.Caption = "";
			this.cboCCN.CaptionHeight = 17;
			this.cboCCN.CharacterCasing = System.Windows.Forms.CharacterCasing.Normal;
			this.cboCCN.ColumnCaptionHeight = 17;
			this.cboCCN.ColumnFooterHeight = 17;
			this.cboCCN.ComboStyle = C1.Win.C1List.ComboStyleEnum.DropdownList;
			this.cboCCN.ContentHeight = 15;
			this.cboCCN.DeadAreaBackColor = System.Drawing.Color.Empty;
			this.cboCCN.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("cboCCN.Dock")));
			this.cboCCN.EditorBackColor = System.Drawing.SystemColors.Window;
			this.cboCCN.EditorFont = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.cboCCN.EditorForeColor = System.Drawing.SystemColors.WindowText;
			this.cboCCN.EditorHeight = 15;
			this.cboCCN.Enabled = ((bool)(resources.GetObject("cboCCN.Enabled")));
			this.cboCCN.Font = ((System.Drawing.Font)(resources.GetObject("cboCCN.Font")));
			this.cboCCN.GapHeight = 2;
			this.cboCCN.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("cboCCN.ImeMode")));
			this.cboCCN.ItemHeight = 15;
			this.cboCCN.Location = ((System.Drawing.Point)(resources.GetObject("cboCCN.Location")));
			this.cboCCN.MatchEntryTimeout = ((long)(2000));
			this.cboCCN.MaxDropDownItems = ((short)(5));
			this.cboCCN.MaxLength = 32767;
			this.cboCCN.MouseCursor = System.Windows.Forms.Cursors.Default;
			this.cboCCN.Name = "cboCCN";
			this.cboCCN.PartialRightColumn = false;
			this.cboCCN.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("cboCCN.RightToLeft")));
			this.cboCCN.RowDivider.Color = System.Drawing.Color.DarkGray;
			this.cboCCN.RowDivider.Style = C1.Win.C1List.LineStyleEnum.None;
			this.cboCCN.RowSubDividerColor = System.Drawing.Color.DarkGray;
			this.cboCCN.Size = ((System.Drawing.Size)(resources.GetObject("cboCCN.Size")));
			this.cboCCN.TabIndex = ((int)(resources.GetObject("cboCCN.TabIndex")));
			this.cboCCN.Text = resources.GetString("cboCCN.Text");
			this.cboCCN.Visible = ((bool)(resources.GetObject("cboCCN.Visible")));
			this.cboCCN.PropBag = "<?xml version=\"1.0\"?><Blob><Styles type=\"C1.Win.C1List.Design.ContextWrapper\"><Da" +
				"ta>Group{AlignVert:Center;Border:None,,0, 0, 0, 0;BackColor:ControlDark;}Style2{" +
				"}Style5{}Style4{}Style7{}Style6{}EvenRow{BackColor:Aqua;}Selected{ForeColor:High" +
				"lightText;BackColor:Highlight;}Style3{}Inactive{ForeColor:InactiveCaptionText;Ba" +
				"ckColor:InactiveCaption;}Footer{}Caption{AlignHorz:Center;}Normal{BackColor:Wind" +
				"ow;}HighlightRow{ForeColor:HighlightText;BackColor:Highlight;}Style1{}OddRow{}Re" +
				"cordSelector{AlignImage:Center;}Heading{Wrap:True;BackColor:Control;Border:Raise" +
				"d,,1, 1, 1, 1;ForeColor:ControlText;AlignVert:Center;}Style8{}Style10{}Style11{}" +
				"Style9{AlignHorz:Near;}</Data></Styles><Splits><C1.Win.C1List.ListBoxView AllowC" +
				"olSelect=\"False\" Name=\"\" CaptionHeight=\"17\" ColumnCaptionHeight=\"17\" ColumnFoote" +
				"rHeight=\"17\" VerticalScrollGroup=\"1\" HorizontalScrollGroup=\"1\"><ClientRect>0, 0," +
				" 116, 156</ClientRect><VScrollBar><Width>16</Width></VScrollBar><HScrollBar><Hei" +
				"ght>16</Height></HScrollBar><CaptionStyle parent=\"Style2\" me=\"Style9\" /><EvenRow" +
				"Style parent=\"EvenRow\" me=\"Style7\" /><FooterStyle parent=\"Footer\" me=\"Style3\" />" +
				"<GroupStyle parent=\"Group\" me=\"Style11\" /><HeadingStyle parent=\"Heading\" me=\"Sty" +
				"le2\" /><HighLightRowStyle parent=\"HighlightRow\" me=\"Style6\" /><InactiveStyle par" +
				"ent=\"Inactive\" me=\"Style4\" /><OddRowStyle parent=\"OddRow\" me=\"Style8\" /><RecordS" +
				"electorStyle parent=\"RecordSelector\" me=\"Style10\" /><SelectedStyle parent=\"Selec" +
				"ted\" me=\"Style5\" /><Style parent=\"Normal\" me=\"Style1\" /></C1.Win.C1List.ListBoxV" +
				"iew></Splits><NamedStyles><Style parent=\"\" me=\"Normal\" /><Style parent=\"Normal\" " +
				"me=\"Heading\" /><Style parent=\"Heading\" me=\"Footer\" /><Style parent=\"Heading\" me=" +
				"\"Caption\" /><Style parent=\"Heading\" me=\"Inactive\" /><Style parent=\"Normal\" me=\"S" +
				"elected\" /><Style parent=\"Normal\" me=\"HighlightRow\" /><Style parent=\"Normal\" me=" +
				"\"EvenRow\" /><Style parent=\"Normal\" me=\"OddRow\" /><Style parent=\"Heading\" me=\"Rec" +
				"ordSelector\" /><Style parent=\"Caption\" me=\"Group\" /></NamedStyles><vertSplits>1<" +
				"/vertSplits><horzSplits>1</horzSplits><Layout>Modified</Layout><DefaultRecSelWid" +
				"th>17</DefaultRecSelWidth></Blob>";
			// 
			// btnCycleSearch
			// 
			this.btnCycleSearch.AccessibleDescription = resources.GetString("btnCycleSearch.AccessibleDescription");
			this.btnCycleSearch.AccessibleName = resources.GetString("btnCycleSearch.AccessibleName");
			this.btnCycleSearch.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("btnCycleSearch.Anchor")));
			this.btnCycleSearch.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnCycleSearch.BackgroundImage")));
			this.btnCycleSearch.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("btnCycleSearch.Dock")));
			this.btnCycleSearch.Enabled = ((bool)(resources.GetObject("btnCycleSearch.Enabled")));
			this.btnCycleSearch.FlatStyle = ((System.Windows.Forms.FlatStyle)(resources.GetObject("btnCycleSearch.FlatStyle")));
			this.btnCycleSearch.Font = ((System.Drawing.Font)(resources.GetObject("btnCycleSearch.Font")));
			this.btnCycleSearch.Image = ((System.Drawing.Image)(resources.GetObject("btnCycleSearch.Image")));
			this.btnCycleSearch.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnCycleSearch.ImageAlign")));
			this.btnCycleSearch.ImageIndex = ((int)(resources.GetObject("btnCycleSearch.ImageIndex")));
			this.btnCycleSearch.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("btnCycleSearch.ImeMode")));
			this.btnCycleSearch.Location = ((System.Drawing.Point)(resources.GetObject("btnCycleSearch.Location")));
			this.btnCycleSearch.Name = "btnCycleSearch";
			this.btnCycleSearch.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("btnCycleSearch.RightToLeft")));
			this.btnCycleSearch.Size = ((System.Drawing.Size)(resources.GetObject("btnCycleSearch.Size")));
			this.btnCycleSearch.TabIndex = ((int)(resources.GetObject("btnCycleSearch.TabIndex")));
			this.btnCycleSearch.Text = resources.GetString("btnCycleSearch.Text");
			this.btnCycleSearch.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnCycleSearch.TextAlign")));
			this.btnCycleSearch.Visible = ((bool)(resources.GetObject("btnCycleSearch.Visible")));
			this.btnCycleSearch.Click += new System.EventHandler(this.btnCycleSearch_Click);
			// 
			// txtCycle
			// 
			this.txtCycle.AccessibleDescription = resources.GetString("txtCycle.AccessibleDescription");
			this.txtCycle.AccessibleName = resources.GetString("txtCycle.AccessibleName");
			this.txtCycle.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("txtCycle.Anchor")));
			this.txtCycle.AutoSize = ((bool)(resources.GetObject("txtCycle.AutoSize")));
			this.txtCycle.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("txtCycle.BackgroundImage")));
			this.txtCycle.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("txtCycle.Dock")));
			this.txtCycle.Enabled = ((bool)(resources.GetObject("txtCycle.Enabled")));
			this.txtCycle.Font = ((System.Drawing.Font)(resources.GetObject("txtCycle.Font")));
			this.txtCycle.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("txtCycle.ImeMode")));
			this.txtCycle.Location = ((System.Drawing.Point)(resources.GetObject("txtCycle.Location")));
			this.txtCycle.MaxLength = ((int)(resources.GetObject("txtCycle.MaxLength")));
			this.txtCycle.Multiline = ((bool)(resources.GetObject("txtCycle.Multiline")));
			this.txtCycle.Name = "txtCycle";
			this.txtCycle.PasswordChar = ((char)(resources.GetObject("txtCycle.PasswordChar")));
			this.txtCycle.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("txtCycle.RightToLeft")));
			this.txtCycle.ScrollBars = ((System.Windows.Forms.ScrollBars)(resources.GetObject("txtCycle.ScrollBars")));
			this.txtCycle.Size = ((System.Drawing.Size)(resources.GetObject("txtCycle.Size")));
			this.txtCycle.TabIndex = ((int)(resources.GetObject("txtCycle.TabIndex")));
			this.txtCycle.Text = resources.GetString("txtCycle.Text");
			this.txtCycle.TextAlign = ((System.Windows.Forms.HorizontalAlignment)(resources.GetObject("txtCycle.TextAlign")));
			this.txtCycle.Visible = ((bool)(resources.GetObject("txtCycle.Visible")));
			this.txtCycle.WordWrap = ((bool)(resources.GetObject("txtCycle.WordWrap")));
			this.txtCycle.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtCycle_KeyDown);
			this.txtCycle.Validating += new System.ComponentModel.CancelEventHandler(this.txtCycle_Validating);
			// 
			// lblCycle
			// 
			this.lblCycle.AccessibleDescription = resources.GetString("lblCycle.AccessibleDescription");
			this.lblCycle.AccessibleName = resources.GetString("lblCycle.AccessibleName");
			this.lblCycle.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("lblCycle.Anchor")));
			this.lblCycle.AutoSize = ((bool)(resources.GetObject("lblCycle.AutoSize")));
			this.lblCycle.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("lblCycle.Dock")));
			this.lblCycle.Enabled = ((bool)(resources.GetObject("lblCycle.Enabled")));
			this.lblCycle.Font = ((System.Drawing.Font)(resources.GetObject("lblCycle.Font")));
			this.lblCycle.ForeColor = System.Drawing.Color.Maroon;
			this.lblCycle.Image = ((System.Drawing.Image)(resources.GetObject("lblCycle.Image")));
			this.lblCycle.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("lblCycle.ImageAlign")));
			this.lblCycle.ImageIndex = ((int)(resources.GetObject("lblCycle.ImageIndex")));
			this.lblCycle.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("lblCycle.ImeMode")));
			this.lblCycle.Location = ((System.Drawing.Point)(resources.GetObject("lblCycle.Location")));
			this.lblCycle.Name = "lblCycle";
			this.lblCycle.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("lblCycle.RightToLeft")));
			this.lblCycle.Size = ((System.Drawing.Size)(resources.GetObject("lblCycle.Size")));
			this.lblCycle.TabIndex = ((int)(resources.GetObject("lblCycle.TabIndex")));
			this.lblCycle.Text = resources.GetString("lblCycle.Text");
			this.lblCycle.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("lblCycle.TextAlign")));
			this.lblCycle.Visible = ((bool)(resources.GetObject("lblCycle.Visible")));
			// 
			// lblCCN
			// 
			this.lblCCN.AccessibleDescription = resources.GetString("lblCCN.AccessibleDescription");
			this.lblCCN.AccessibleName = resources.GetString("lblCCN.AccessibleName");
			this.lblCCN.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("lblCCN.Anchor")));
			this.lblCCN.AutoSize = ((bool)(resources.GetObject("lblCCN.AutoSize")));
			this.lblCCN.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("lblCCN.Dock")));
			this.lblCCN.Enabled = ((bool)(resources.GetObject("lblCCN.Enabled")));
			this.lblCCN.Font = ((System.Drawing.Font)(resources.GetObject("lblCCN.Font")));
			this.lblCCN.ForeColor = System.Drawing.Color.Maroon;
			this.lblCCN.Image = ((System.Drawing.Image)(resources.GetObject("lblCCN.Image")));
			this.lblCCN.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("lblCCN.ImageAlign")));
			this.lblCCN.ImageIndex = ((int)(resources.GetObject("lblCCN.ImageIndex")));
			this.lblCCN.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("lblCCN.ImeMode")));
			this.lblCCN.Location = ((System.Drawing.Point)(resources.GetObject("lblCCN.Location")));
			this.lblCCN.Name = "lblCCN";
			this.lblCCN.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("lblCCN.RightToLeft")));
			this.lblCCN.Size = ((System.Drawing.Size)(resources.GetObject("lblCCN.Size")));
			this.lblCCN.TabIndex = ((int)(resources.GetObject("lblCCN.TabIndex")));
			this.lblCCN.Text = resources.GetString("lblCCN.Text");
			this.lblCCN.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("lblCCN.TextAlign")));
			this.lblCCN.Visible = ((bool)(resources.GetObject("lblCCN.Visible")));
			// 
			// dgrdData
			// 
			this.dgrdData.AccessibleDescription = resources.GetString("dgrdData.AccessibleDescription");
			this.dgrdData.AccessibleName = resources.GetString("dgrdData.AccessibleName");
			this.dgrdData.AllowAddNew = ((bool)(resources.GetObject("dgrdData.AllowAddNew")));
			this.dgrdData.AllowArrows = ((bool)(resources.GetObject("dgrdData.AllowArrows")));
			this.dgrdData.AllowColMove = ((bool)(resources.GetObject("dgrdData.AllowColMove")));
			this.dgrdData.AllowColSelect = ((bool)(resources.GetObject("dgrdData.AllowColSelect")));
			this.dgrdData.AllowDelete = ((bool)(resources.GetObject("dgrdData.AllowDelete")));
			this.dgrdData.AllowDrag = ((bool)(resources.GetObject("dgrdData.AllowDrag")));
			this.dgrdData.AllowFilter = ((bool)(resources.GetObject("dgrdData.AllowFilter")));
			this.dgrdData.AllowHorizontalSplit = ((bool)(resources.GetObject("dgrdData.AllowHorizontalSplit")));
			this.dgrdData.AllowRowSelect = ((bool)(resources.GetObject("dgrdData.AllowRowSelect")));
			this.dgrdData.AllowSort = ((bool)(resources.GetObject("dgrdData.AllowSort")));
			this.dgrdData.AllowUpdate = ((bool)(resources.GetObject("dgrdData.AllowUpdate")));
			this.dgrdData.AllowUpdateOnBlur = ((bool)(resources.GetObject("dgrdData.AllowUpdateOnBlur")));
			this.dgrdData.AllowVerticalSplit = ((bool)(resources.GetObject("dgrdData.AllowVerticalSplit")));
			this.dgrdData.AlternatingRows = ((bool)(resources.GetObject("dgrdData.AlternatingRows")));
			this.dgrdData.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("dgrdData.Anchor")));
			this.dgrdData.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("dgrdData.BackgroundImage")));
			this.dgrdData.BorderStyle = ((System.Windows.Forms.BorderStyle)(resources.GetObject("dgrdData.BorderStyle")));
			this.dgrdData.Caption = resources.GetString("dgrdData.Caption");
			this.dgrdData.CaptionHeight = ((int)(resources.GetObject("dgrdData.CaptionHeight")));
			this.dgrdData.CellTipsDelay = ((int)(resources.GetObject("dgrdData.CellTipsDelay")));
			this.dgrdData.CellTipsWidth = ((int)(resources.GetObject("dgrdData.CellTipsWidth")));
			this.dgrdData.ChildGrid = ((C1.Win.C1TrueDBGrid.C1TrueDBGrid)(resources.GetObject("dgrdData.ChildGrid")));
			this.dgrdData.CollapseColor = ((System.Drawing.Color)(resources.GetObject("dgrdData.CollapseColor")));
			this.dgrdData.ColumnFooters = ((bool)(resources.GetObject("dgrdData.ColumnFooters")));
			this.dgrdData.ColumnHeaders = ((bool)(resources.GetObject("dgrdData.ColumnHeaders")));
			this.dgrdData.DefColWidth = ((int)(resources.GetObject("dgrdData.DefColWidth")));
			this.dgrdData.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("dgrdData.Dock")));
			this.dgrdData.EditDropDown = ((bool)(resources.GetObject("dgrdData.EditDropDown")));
			this.dgrdData.EmptyRows = ((bool)(resources.GetObject("dgrdData.EmptyRows")));
			this.dgrdData.Enabled = ((bool)(resources.GetObject("dgrdData.Enabled")));
			this.dgrdData.ExpandColor = ((System.Drawing.Color)(resources.GetObject("dgrdData.ExpandColor")));
			this.dgrdData.ExposeCellMode = ((C1.Win.C1TrueDBGrid.ExposeCellModeEnum)(resources.GetObject("dgrdData.ExposeCellMode")));
			this.dgrdData.ExtendRightColumn = ((bool)(resources.GetObject("dgrdData.ExtendRightColumn")));
			this.dgrdData.FetchRowStyles = ((bool)(resources.GetObject("dgrdData.FetchRowStyles")));
			this.dgrdData.FilterBar = ((bool)(resources.GetObject("dgrdData.FilterBar")));
			this.dgrdData.FlatStyle = ((C1.Win.C1TrueDBGrid.FlatModeEnum)(resources.GetObject("dgrdData.FlatStyle")));
			this.dgrdData.Font = ((System.Drawing.Font)(resources.GetObject("dgrdData.Font")));
			this.dgrdData.GroupByAreaVisible = ((bool)(resources.GetObject("dgrdData.GroupByAreaVisible")));
			this.dgrdData.GroupByCaption = resources.GetString("dgrdData.GroupByCaption");
			this.dgrdData.Images.Add(((System.Drawing.Image)(resources.GetObject("resource"))));
			this.dgrdData.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("dgrdData.ImeMode")));
			this.dgrdData.LinesPerRow = ((int)(resources.GetObject("dgrdData.LinesPerRow")));
			this.dgrdData.Location = ((System.Drawing.Point)(resources.GetObject("dgrdData.Location")));
			this.dgrdData.MarqueeStyle = C1.Win.C1TrueDBGrid.MarqueeEnum.DottedCellBorder;
			this.dgrdData.Name = "dgrdData";
			this.dgrdData.PictureAddnewRow = ((System.Drawing.Image)(resources.GetObject("dgrdData.PictureAddnewRow")));
			this.dgrdData.PictureCurrentRow = ((System.Drawing.Image)(resources.GetObject("dgrdData.PictureCurrentRow")));
			this.dgrdData.PictureFilterBar = ((System.Drawing.Image)(resources.GetObject("dgrdData.PictureFilterBar")));
			this.dgrdData.PictureFooterRow = ((System.Drawing.Image)(resources.GetObject("dgrdData.PictureFooterRow")));
			this.dgrdData.PictureHeaderRow = ((System.Drawing.Image)(resources.GetObject("dgrdData.PictureHeaderRow")));
			this.dgrdData.PictureModifiedRow = ((System.Drawing.Image)(resources.GetObject("dgrdData.PictureModifiedRow")));
			this.dgrdData.PictureStandardRow = ((System.Drawing.Image)(resources.GetObject("dgrdData.PictureStandardRow")));
			this.dgrdData.PreviewInfo.AllowSizing = ((bool)(resources.GetObject("dgrdData.PreviewInfo.AllowSizing")));
			this.dgrdData.PreviewInfo.Caption = resources.GetString("dgrdData.PreviewInfo.Caption");
			this.dgrdData.PreviewInfo.Location = ((System.Drawing.Point)(resources.GetObject("dgrdData.PreviewInfo.Location")));
			this.dgrdData.PreviewInfo.Size = ((System.Drawing.Size)(resources.GetObject("dgrdData.PreviewInfo.Size")));
			this.dgrdData.PreviewInfo.ToolBars = ((bool)(resources.GetObject("dgrdData.PreviewInfo.ToolBars")));
			this.dgrdData.PreviewInfo.UIStrings.Content = ((string[])(resources.GetObject("dgrdData.PreviewInfo.UIStrings.Content")));
			this.dgrdData.PreviewInfo.ZoomFactor = ((System.Double)(resources.GetObject("dgrdData.PreviewInfo.ZoomFactor")));
			this.dgrdData.PrintInfo.MaxRowHeight = ((int)(resources.GetObject("dgrdData.PrintInfo.MaxRowHeight")));
			this.dgrdData.PrintInfo.OwnerDrawPageFooter = ((bool)(resources.GetObject("dgrdData.PrintInfo.OwnerDrawPageFooter")));
			this.dgrdData.PrintInfo.OwnerDrawPageHeader = ((bool)(resources.GetObject("dgrdData.PrintInfo.OwnerDrawPageHeader")));
			this.dgrdData.PrintInfo.PageFooter = resources.GetString("dgrdData.PrintInfo.PageFooter");
			this.dgrdData.PrintInfo.PageFooterHeight = ((int)(resources.GetObject("dgrdData.PrintInfo.PageFooterHeight")));
			this.dgrdData.PrintInfo.PageHeader = resources.GetString("dgrdData.PrintInfo.PageHeader");
			this.dgrdData.PrintInfo.PageHeaderHeight = ((int)(resources.GetObject("dgrdData.PrintInfo.PageHeaderHeight")));
			this.dgrdData.PrintInfo.PrintHorizontalSplits = ((bool)(resources.GetObject("dgrdData.PrintInfo.PrintHorizontalSplits")));
			this.dgrdData.PrintInfo.ProgressCaption = resources.GetString("dgrdData.PrintInfo.ProgressCaption");
			this.dgrdData.PrintInfo.RepeatColumnFooters = ((bool)(resources.GetObject("dgrdData.PrintInfo.RepeatColumnFooters")));
			this.dgrdData.PrintInfo.RepeatColumnHeaders = ((bool)(resources.GetObject("dgrdData.PrintInfo.RepeatColumnHeaders")));
			this.dgrdData.PrintInfo.RepeatGridHeader = ((bool)(resources.GetObject("dgrdData.PrintInfo.RepeatGridHeader")));
			this.dgrdData.PrintInfo.RepeatSplitHeaders = ((bool)(resources.GetObject("dgrdData.PrintInfo.RepeatSplitHeaders")));
			this.dgrdData.PrintInfo.ShowOptionsDialog = ((bool)(resources.GetObject("dgrdData.PrintInfo.ShowOptionsDialog")));
			this.dgrdData.PrintInfo.ShowProgressForm = ((bool)(resources.GetObject("dgrdData.PrintInfo.ShowProgressForm")));
			this.dgrdData.PrintInfo.ShowSelection = ((bool)(resources.GetObject("dgrdData.PrintInfo.ShowSelection")));
			this.dgrdData.PrintInfo.UseGridColors = ((bool)(resources.GetObject("dgrdData.PrintInfo.UseGridColors")));
			this.dgrdData.RecordSelectors = ((bool)(resources.GetObject("dgrdData.RecordSelectors")));
			this.dgrdData.RecordSelectorWidth = ((int)(resources.GetObject("dgrdData.RecordSelectorWidth")));
			this.dgrdData.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("dgrdData.RightToLeft")));
			this.dgrdData.RowDivider.Color = ((System.Drawing.Color)(resources.GetObject("resource.Color")));
			this.dgrdData.RowDivider.Style = ((C1.Win.C1TrueDBGrid.LineStyleEnum)(resources.GetObject("resource.Style")));
			this.dgrdData.RowHeight = ((int)(resources.GetObject("dgrdData.RowHeight")));
			this.dgrdData.RowSubDividerColor = ((System.Drawing.Color)(resources.GetObject("dgrdData.RowSubDividerColor")));
			this.dgrdData.ScrollTips = ((bool)(resources.GetObject("dgrdData.ScrollTips")));
			this.dgrdData.ScrollTrack = ((bool)(resources.GetObject("dgrdData.ScrollTrack")));
			this.dgrdData.Size = ((System.Drawing.Size)(resources.GetObject("dgrdData.Size")));
			this.dgrdData.SpringMode = ((bool)(resources.GetObject("dgrdData.SpringMode")));
			this.dgrdData.TabAcrossSplits = ((bool)(resources.GetObject("dgrdData.TabAcrossSplits")));
			this.dgrdData.TabIndex = ((int)(resources.GetObject("dgrdData.TabIndex")));
			this.dgrdData.Text = resources.GetString("dgrdData.Text");
			this.dgrdData.ViewCaptionWidth = ((int)(resources.GetObject("dgrdData.ViewCaptionWidth")));
			this.dgrdData.ViewColumnWidth = ((int)(resources.GetObject("dgrdData.ViewColumnWidth")));
			this.dgrdData.Visible = ((bool)(resources.GetObject("dgrdData.Visible")));
			this.dgrdData.WrapCellPointer = ((bool)(resources.GetObject("dgrdData.WrapCellPointer")));
			this.dgrdData.ButtonClick += new C1.Win.C1TrueDBGrid.ColEventHandler(this.dgrdData_ButtonClick);
			this.dgrdData.AfterColUpdate += new C1.Win.C1TrueDBGrid.ColEventHandler(this.dgrdData_AfterColUpdate);
			this.dgrdData.KeyDown += new System.Windows.Forms.KeyEventHandler(this.dgrdData_KeyDown);
			this.dgrdData.PropBag = resources.GetString("dgrdData.PropBag");
			// 
			// btnSave
			// 
			this.btnSave.AccessibleDescription = resources.GetString("btnSave.AccessibleDescription");
			this.btnSave.AccessibleName = resources.GetString("btnSave.AccessibleName");
			this.btnSave.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("btnSave.Anchor")));
			this.btnSave.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnSave.BackgroundImage")));
			this.btnSave.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("btnSave.Dock")));
			this.btnSave.Enabled = ((bool)(resources.GetObject("btnSave.Enabled")));
			this.btnSave.FlatStyle = ((System.Windows.Forms.FlatStyle)(resources.GetObject("btnSave.FlatStyle")));
			this.btnSave.Font = ((System.Drawing.Font)(resources.GetObject("btnSave.Font")));
			this.btnSave.Image = ((System.Drawing.Image)(resources.GetObject("btnSave.Image")));
			this.btnSave.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnSave.ImageAlign")));
			this.btnSave.ImageIndex = ((int)(resources.GetObject("btnSave.ImageIndex")));
			this.btnSave.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("btnSave.ImeMode")));
			this.btnSave.Location = ((System.Drawing.Point)(resources.GetObject("btnSave.Location")));
			this.btnSave.Name = "btnSave";
			this.btnSave.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("btnSave.RightToLeft")));
			this.btnSave.Size = ((System.Drawing.Size)(resources.GetObject("btnSave.Size")));
			this.btnSave.TabIndex = ((int)(resources.GetObject("btnSave.TabIndex")));
			this.btnSave.Text = resources.GetString("btnSave.Text");
			this.btnSave.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnSave.TextAlign")));
			this.btnSave.Visible = ((bool)(resources.GetObject("btnSave.Visible")));
			this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
			// 
			// btnClose
			// 
			this.btnClose.AccessibleDescription = resources.GetString("btnClose.AccessibleDescription");
			this.btnClose.AccessibleName = resources.GetString("btnClose.AccessibleName");
			this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("btnClose.Anchor")));
			this.btnClose.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnClose.BackgroundImage")));
			this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.btnClose.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("btnClose.Dock")));
			this.btnClose.Enabled = ((bool)(resources.GetObject("btnClose.Enabled")));
			this.btnClose.FlatStyle = ((System.Windows.Forms.FlatStyle)(resources.GetObject("btnClose.FlatStyle")));
			this.btnClose.Font = ((System.Drawing.Font)(resources.GetObject("btnClose.Font")));
			this.btnClose.Image = ((System.Drawing.Image)(resources.GetObject("btnClose.Image")));
			this.btnClose.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnClose.ImageAlign")));
			this.btnClose.ImageIndex = ((int)(resources.GetObject("btnClose.ImageIndex")));
			this.btnClose.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("btnClose.ImeMode")));
			this.btnClose.Location = ((System.Drawing.Point)(resources.GetObject("btnClose.Location")));
			this.btnClose.Name = "btnClose";
			this.btnClose.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("btnClose.RightToLeft")));
			this.btnClose.Size = ((System.Drawing.Size)(resources.GetObject("btnClose.Size")));
			this.btnClose.TabIndex = ((int)(resources.GetObject("btnClose.TabIndex")));
			this.btnClose.Text = resources.GetString("btnClose.Text");
			this.btnClose.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnClose.TextAlign")));
			this.btnClose.Visible = ((bool)(resources.GetObject("btnClose.Visible")));
			this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
			// 
			// btnHelp
			// 
			this.btnHelp.AccessibleDescription = resources.GetString("btnHelp.AccessibleDescription");
			this.btnHelp.AccessibleName = resources.GetString("btnHelp.AccessibleName");
			this.btnHelp.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("btnHelp.Anchor")));
			this.btnHelp.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnHelp.BackgroundImage")));
			this.btnHelp.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("btnHelp.Dock")));
			this.btnHelp.Enabled = ((bool)(resources.GetObject("btnHelp.Enabled")));
			this.btnHelp.FlatStyle = ((System.Windows.Forms.FlatStyle)(resources.GetObject("btnHelp.FlatStyle")));
			this.btnHelp.Font = ((System.Drawing.Font)(resources.GetObject("btnHelp.Font")));
			this.btnHelp.Image = ((System.Drawing.Image)(resources.GetObject("btnHelp.Image")));
			this.btnHelp.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnHelp.ImageAlign")));
			this.btnHelp.ImageIndex = ((int)(resources.GetObject("btnHelp.ImageIndex")));
			this.btnHelp.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("btnHelp.ImeMode")));
			this.btnHelp.Location = ((System.Drawing.Point)(resources.GetObject("btnHelp.Location")));
			this.btnHelp.Name = "btnHelp";
			this.btnHelp.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("btnHelp.RightToLeft")));
			this.btnHelp.Size = ((System.Drawing.Size)(resources.GetObject("btnHelp.Size")));
			this.btnHelp.TabIndex = ((int)(resources.GetObject("btnHelp.TabIndex")));
			this.btnHelp.Text = resources.GetString("btnHelp.Text");
			this.btnHelp.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnHelp.TextAlign")));
			this.btnHelp.Visible = ((bool)(resources.GetObject("btnHelp.Visible")));
			// 
			// btnGenerate
			// 
			this.btnGenerate.AccessibleDescription = resources.GetString("btnGenerate.AccessibleDescription");
			this.btnGenerate.AccessibleName = resources.GetString("btnGenerate.AccessibleName");
			this.btnGenerate.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("btnGenerate.Anchor")));
			this.btnGenerate.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnGenerate.BackgroundImage")));
			this.btnGenerate.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("btnGenerate.Dock")));
			this.btnGenerate.Enabled = ((bool)(resources.GetObject("btnGenerate.Enabled")));
			this.btnGenerate.FlatStyle = ((System.Windows.Forms.FlatStyle)(resources.GetObject("btnGenerate.FlatStyle")));
			this.btnGenerate.Font = ((System.Drawing.Font)(resources.GetObject("btnGenerate.Font")));
			this.btnGenerate.Image = ((System.Drawing.Image)(resources.GetObject("btnGenerate.Image")));
			this.btnGenerate.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnGenerate.ImageAlign")));
			this.btnGenerate.ImageIndex = ((int)(resources.GetObject("btnGenerate.ImageIndex")));
			this.btnGenerate.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("btnGenerate.ImeMode")));
			this.btnGenerate.Location = ((System.Drawing.Point)(resources.GetObject("btnGenerate.Location")));
			this.btnGenerate.Name = "btnGenerate";
			this.btnGenerate.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("btnGenerate.RightToLeft")));
			this.btnGenerate.Size = ((System.Drawing.Size)(resources.GetObject("btnGenerate.Size")));
			this.btnGenerate.TabIndex = ((int)(resources.GetObject("btnGenerate.TabIndex")));
			this.btnGenerate.Text = resources.GetString("btnGenerate.Text");
			this.btnGenerate.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnGenerate.TextAlign")));
			this.btnGenerate.Visible = ((bool)(resources.GetObject("btnGenerate.Visible")));
			this.btnGenerate.Click += new System.EventHandler(this.btnGenerate_Click);
			// 
			// btnSearch
			// 
			this.btnSearch.AccessibleDescription = resources.GetString("btnSearch.AccessibleDescription");
			this.btnSearch.AccessibleName = resources.GetString("btnSearch.AccessibleName");
			this.btnSearch.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("btnSearch.Anchor")));
			this.btnSearch.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnSearch.BackgroundImage")));
			this.btnSearch.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("btnSearch.Dock")));
			this.btnSearch.Enabled = ((bool)(resources.GetObject("btnSearch.Enabled")));
			this.btnSearch.FlatStyle = ((System.Windows.Forms.FlatStyle)(resources.GetObject("btnSearch.FlatStyle")));
			this.btnSearch.Font = ((System.Drawing.Font)(resources.GetObject("btnSearch.Font")));
			this.btnSearch.Image = ((System.Drawing.Image)(resources.GetObject("btnSearch.Image")));
			this.btnSearch.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnSearch.ImageAlign")));
			this.btnSearch.ImageIndex = ((int)(resources.GetObject("btnSearch.ImageIndex")));
			this.btnSearch.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("btnSearch.ImeMode")));
			this.btnSearch.Location = ((System.Drawing.Point)(resources.GetObject("btnSearch.Location")));
			this.btnSearch.Name = "btnSearch";
			this.btnSearch.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("btnSearch.RightToLeft")));
			this.btnSearch.Size = ((System.Drawing.Size)(resources.GetObject("btnSearch.Size")));
			this.btnSearch.TabIndex = ((int)(resources.GetObject("btnSearch.TabIndex")));
			this.btnSearch.Text = resources.GetString("btnSearch.Text");
			this.btnSearch.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnSearch.TextAlign")));
			this.btnSearch.Visible = ((bool)(resources.GetObject("btnSearch.Visible")));
			this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
			// 
			// dtmDate
			// 
			this.dtmDate.AcceptsEscape = ((bool)(resources.GetObject("dtmDate.AcceptsEscape")));
			this.dtmDate.AccessibleDescription = resources.GetString("dtmDate.AccessibleDescription");
			this.dtmDate.AccessibleName = resources.GetString("dtmDate.AccessibleName");
			this.dtmDate.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("dtmDate.Anchor")));
			this.dtmDate.AutoSize = ((bool)(resources.GetObject("dtmDate.AutoSize")));
			this.dtmDate.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("dtmDate.BackgroundImage")));
			this.dtmDate.BorderStyle = ((System.Windows.Forms.BorderStyle)(resources.GetObject("dtmDate.BorderStyle")));
			// 
			// dtmDate.Calendar
			// 
			this.dtmDate.Calendar.AccessibleDescription = resources.GetString("dtmDate.Calendar.AccessibleDescription");
			this.dtmDate.Calendar.AccessibleName = resources.GetString("dtmDate.Calendar.AccessibleName");
			this.dtmDate.Calendar.AnnuallyBoldedDates = ((System.DateTime[])(resources.GetObject("dtmDate.Calendar.AnnuallyBoldedDates")));
			this.dtmDate.Calendar.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("dtmDate.Calendar.BackgroundImage")));
			this.dtmDate.Calendar.BoldedDates = ((System.DateTime[])(resources.GetObject("dtmDate.Calendar.BoldedDates")));
			this.dtmDate.Calendar.CalendarDimensions = ((System.Drawing.Size)(resources.GetObject("dtmDate.Calendar.CalendarDimensions")));
			this.dtmDate.Calendar.Enabled = ((bool)(resources.GetObject("dtmDate.Calendar.Enabled")));
			this.dtmDate.Calendar.FirstDayOfWeek = ((System.Windows.Forms.Day)(resources.GetObject("dtmDate.Calendar.FirstDayOfWeek")));
			this.dtmDate.Calendar.Font = ((System.Drawing.Font)(resources.GetObject("dtmDate.Calendar.Font")));
			this.dtmDate.Calendar.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("dtmDate.Calendar.ImeMode")));
			this.dtmDate.Calendar.MonthlyBoldedDates = ((System.DateTime[])(resources.GetObject("dtmDate.Calendar.MonthlyBoldedDates")));
			this.dtmDate.Calendar.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("dtmDate.Calendar.RightToLeft")));
			this.dtmDate.Calendar.ShowClearButton = ((bool)(resources.GetObject("dtmDate.Calendar.ShowClearButton")));
			this.dtmDate.Calendar.ShowTodayButton = ((bool)(resources.GetObject("dtmDate.Calendar.ShowTodayButton")));
			this.dtmDate.Calendar.ShowWeekNumbers = ((bool)(resources.GetObject("dtmDate.Calendar.ShowWeekNumbers")));
			this.dtmDate.CaseSensitive = ((bool)(resources.GetObject("dtmDate.CaseSensitive")));
			this.dtmDate.Culture = ((int)(resources.GetObject("dtmDate.Culture")));
			this.dtmDate.CurrentTimeZone = ((bool)(resources.GetObject("dtmDate.CurrentTimeZone")));
			this.dtmDate.CustomFormat = resources.GetString("dtmDate.CustomFormat");
			this.dtmDate.DaylightTimeAdjustment = ((C1.Win.C1Input.DaylightTimeAdjustmentEnum)(resources.GetObject("dtmDate.DaylightTimeAdjustment")));
			this.dtmDate.DisplayFormat.CustomFormat = resources.GetString("dtmDate.DisplayFormat.CustomFormat");
			this.dtmDate.DisplayFormat.FormatType = ((C1.Win.C1Input.FormatTypeEnum)(resources.GetObject("dtmDate.DisplayFormat.FormatType")));
			this.dtmDate.DisplayFormat.Inherit = ((C1.Win.C1Input.FormatInfoInheritFlags)(resources.GetObject("dtmDate.DisplayFormat.Inherit")));
			this.dtmDate.DisplayFormat.NullText = resources.GetString("dtmDate.DisplayFormat.NullText");
			this.dtmDate.DisplayFormat.TrimEnd = ((bool)(resources.GetObject("dtmDate.DisplayFormat.TrimEnd")));
			this.dtmDate.DisplayFormat.TrimStart = ((bool)(resources.GetObject("dtmDate.DisplayFormat.TrimStart")));
			this.dtmDate.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("dtmDate.Dock")));
			this.dtmDate.DropDownFormAlign = ((C1.Win.C1Input.DropDownFormAlignmentEnum)(resources.GetObject("dtmDate.DropDownFormAlign")));
			this.dtmDate.EditFormat.CustomFormat = resources.GetString("dtmDate.EditFormat.CustomFormat");
			this.dtmDate.EditFormat.FormatType = ((C1.Win.C1Input.FormatTypeEnum)(resources.GetObject("dtmDate.EditFormat.FormatType")));
			this.dtmDate.EditFormat.Inherit = ((C1.Win.C1Input.FormatInfoInheritFlags)(resources.GetObject("dtmDate.EditFormat.Inherit")));
			this.dtmDate.EditFormat.NullText = resources.GetString("dtmDate.EditFormat.NullText");
			this.dtmDate.EditFormat.TrimEnd = ((bool)(resources.GetObject("dtmDate.EditFormat.TrimEnd")));
			this.dtmDate.EditFormat.TrimStart = ((bool)(resources.GetObject("dtmDate.EditFormat.TrimStart")));
			this.dtmDate.EditMask = resources.GetString("dtmDate.EditMask");
			this.dtmDate.EmptyAsNull = ((bool)(resources.GetObject("dtmDate.EmptyAsNull")));
			this.dtmDate.Enabled = ((bool)(resources.GetObject("dtmDate.Enabled")));
			this.dtmDate.ErrorInfo.BeepOnError = ((bool)(resources.GetObject("dtmDate.ErrorInfo.BeepOnError")));
			this.dtmDate.ErrorInfo.ErrorMessage = resources.GetString("dtmDate.ErrorInfo.ErrorMessage");
			this.dtmDate.ErrorInfo.ErrorMessageCaption = resources.GetString("dtmDate.ErrorInfo.ErrorMessageCaption");
			this.dtmDate.ErrorInfo.ShowErrorMessage = ((bool)(resources.GetObject("dtmDate.ErrorInfo.ShowErrorMessage")));
			this.dtmDate.ErrorInfo.ValueOnError = ((object)(resources.GetObject("dtmDate.ErrorInfo.ValueOnError")));
			this.dtmDate.Font = ((System.Drawing.Font)(resources.GetObject("dtmDate.Font")));
			this.dtmDate.FormatType = ((C1.Win.C1Input.FormatTypeEnum)(resources.GetObject("dtmDate.FormatType")));
			this.dtmDate.GapHeight = ((int)(resources.GetObject("dtmDate.GapHeight")));
			this.dtmDate.GMTOffset = ((System.TimeSpan)(resources.GetObject("dtmDate.GMTOffset")));
			this.dtmDate.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("dtmDate.ImeMode")));
			this.dtmDate.InitialSelection = ((C1.Win.C1Input.InitialSelectionEnum)(resources.GetObject("dtmDate.InitialSelection")));
			this.dtmDate.Location = ((System.Drawing.Point)(resources.GetObject("dtmDate.Location")));
			this.dtmDate.MaskInfo.AutoTabWhenFilled = ((bool)(resources.GetObject("dtmDate.MaskInfo.AutoTabWhenFilled")));
			this.dtmDate.MaskInfo.CaseSensitive = ((bool)(resources.GetObject("dtmDate.MaskInfo.CaseSensitive")));
			this.dtmDate.MaskInfo.CopyWithLiterals = ((bool)(resources.GetObject("dtmDate.MaskInfo.CopyWithLiterals")));
			this.dtmDate.MaskInfo.EditMask = resources.GetString("dtmDate.MaskInfo.EditMask");
			this.dtmDate.MaskInfo.EmptyAsNull = ((bool)(resources.GetObject("dtmDate.MaskInfo.EmptyAsNull")));
			this.dtmDate.MaskInfo.ErrorMessage = resources.GetString("dtmDate.MaskInfo.ErrorMessage");
			this.dtmDate.MaskInfo.Inherit = ((C1.Win.C1Input.MaskInfoInheritFlags)(resources.GetObject("dtmDate.MaskInfo.Inherit")));
			this.dtmDate.MaskInfo.PromptChar = ((char)(resources.GetObject("dtmDate.MaskInfo.PromptChar")));
			this.dtmDate.MaskInfo.ShowLiterals = ((C1.Win.C1Input.ShowLiteralsEnum)(resources.GetObject("dtmDate.MaskInfo.ShowLiterals")));
			this.dtmDate.MaskInfo.StoredEmptyChar = ((char)(resources.GetObject("dtmDate.MaskInfo.StoredEmptyChar")));
			this.dtmDate.MaxLength = ((int)(resources.GetObject("dtmDate.MaxLength")));
			this.dtmDate.Name = "dtmDate";
			this.dtmDate.NullText = resources.GetString("dtmDate.NullText");
			this.dtmDate.ParseInfo.CaseSensitive = ((bool)(resources.GetObject("dtmDate.ParseInfo.CaseSensitive")));
			this.dtmDate.ParseInfo.CustomFormat = resources.GetString("dtmDate.ParseInfo.CustomFormat");
			this.dtmDate.ParseInfo.DateTimeStyle = ((C1.Win.C1Input.DateTimeStyleFlags)(resources.GetObject("dtmDate.ParseInfo.DateTimeStyle")));
			this.dtmDate.ParseInfo.EmptyAsNull = ((bool)(resources.GetObject("dtmDate.ParseInfo.EmptyAsNull")));
			this.dtmDate.ParseInfo.ErrorMessage = resources.GetString("dtmDate.ParseInfo.ErrorMessage");
			this.dtmDate.ParseInfo.FormatType = ((C1.Win.C1Input.FormatTypeEnum)(resources.GetObject("dtmDate.ParseInfo.FormatType")));
			this.dtmDate.ParseInfo.Inherit = ((C1.Win.C1Input.ParseInfoInheritFlags)(resources.GetObject("dtmDate.ParseInfo.Inherit")));
			this.dtmDate.ParseInfo.NullText = resources.GetString("dtmDate.ParseInfo.NullText");
			this.dtmDate.ParseInfo.TrimEnd = ((bool)(resources.GetObject("dtmDate.ParseInfo.TrimEnd")));
			this.dtmDate.ParseInfo.TrimStart = ((bool)(resources.GetObject("dtmDate.ParseInfo.TrimStart")));
			this.dtmDate.PasswordChar = ((char)(resources.GetObject("dtmDate.PasswordChar")));
			this.dtmDate.PostValidation.CaseSensitive = ((bool)(resources.GetObject("dtmDate.PostValidation.CaseSensitive")));
			this.dtmDate.PostValidation.ErrorMessage = resources.GetString("dtmDate.PostValidation.ErrorMessage");
			this.dtmDate.PostValidation.Inherit = ((C1.Win.C1Input.PostValidationInheritFlags)(resources.GetObject("dtmDate.PostValidation.Inherit")));
			this.dtmDate.PostValidation.Validation = ((C1.Win.C1Input.PostValidationTypeEnum)(resources.GetObject("dtmDate.PostValidation.Validation")));
			this.dtmDate.PostValidation.Values = ((System.Array)(resources.GetObject("dtmDate.PostValidation.Values")));
			this.dtmDate.PostValidation.ValuesExcluded = ((System.Array)(resources.GetObject("dtmDate.PostValidation.ValuesExcluded")));
			this.dtmDate.PreValidation.CaseSensitive = ((bool)(resources.GetObject("dtmDate.PreValidation.CaseSensitive")));
			this.dtmDate.PreValidation.ErrorMessage = resources.GetString("dtmDate.PreValidation.ErrorMessage");
			this.dtmDate.PreValidation.Inherit = ((C1.Win.C1Input.PreValidationInheritFlags)(resources.GetObject("dtmDate.PreValidation.Inherit")));
			this.dtmDate.PreValidation.ItemSeparator = resources.GetString("dtmDate.PreValidation.ItemSeparator");
			this.dtmDate.PreValidation.PatternString = resources.GetString("dtmDate.PreValidation.PatternString");
			this.dtmDate.PreValidation.RegexOptions = ((C1.Win.C1Input.RegexOptionFlags)(resources.GetObject("dtmDate.PreValidation.RegexOptions")));
			this.dtmDate.PreValidation.TrimEnd = ((bool)(resources.GetObject("dtmDate.PreValidation.TrimEnd")));
			this.dtmDate.PreValidation.TrimStart = ((bool)(resources.GetObject("dtmDate.PreValidation.TrimStart")));
			this.dtmDate.PreValidation.Validation = ((C1.Win.C1Input.PreValidationTypeEnum)(resources.GetObject("dtmDate.PreValidation.Validation")));
			this.dtmDate.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("dtmDate.RightToLeft")));
			this.dtmDate.ShowFocusRectangle = ((bool)(resources.GetObject("dtmDate.ShowFocusRectangle")));
			this.dtmDate.Size = ((System.Drawing.Size)(resources.GetObject("dtmDate.Size")));
			this.dtmDate.TabIndex = ((int)(resources.GetObject("dtmDate.TabIndex")));
			this.dtmDate.Tag = ((object)(resources.GetObject("dtmDate.Tag")));
			this.dtmDate.TextAlign = ((System.Windows.Forms.HorizontalAlignment)(resources.GetObject("dtmDate.TextAlign")));
			this.dtmDate.TrimEnd = ((bool)(resources.GetObject("dtmDate.TrimEnd")));
			this.dtmDate.TrimStart = ((bool)(resources.GetObject("dtmDate.TrimStart")));
			this.dtmDate.UserCultureOverride = ((bool)(resources.GetObject("dtmDate.UserCultureOverride")));
			this.dtmDate.Value = ((object)(resources.GetObject("dtmDate.Value")));
			this.dtmDate.VerticalAlign = ((C1.Win.C1Input.VerticalAlignEnum)(resources.GetObject("dtmDate.VerticalAlign")));
			this.dtmDate.Visible = ((bool)(resources.GetObject("dtmDate.Visible")));
			this.dtmDate.VisibleButtons = ((C1.Win.C1Input.DropDownControlButtonFlags)(resources.GetObject("dtmDate.VisibleButtons")));
			// 
			// btnCutOver
			// 
			this.btnCutOver.AccessibleDescription = resources.GetString("btnCutOver.AccessibleDescription");
			this.btnCutOver.AccessibleName = resources.GetString("btnCutOver.AccessibleName");
			this.btnCutOver.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("btnCutOver.Anchor")));
			this.btnCutOver.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnCutOver.BackgroundImage")));
			this.btnCutOver.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("btnCutOver.Dock")));
			this.btnCutOver.Enabled = ((bool)(resources.GetObject("btnCutOver.Enabled")));
			this.btnCutOver.FlatStyle = ((System.Windows.Forms.FlatStyle)(resources.GetObject("btnCutOver.FlatStyle")));
			this.btnCutOver.Font = ((System.Drawing.Font)(resources.GetObject("btnCutOver.Font")));
			this.btnCutOver.Image = ((System.Drawing.Image)(resources.GetObject("btnCutOver.Image")));
			this.btnCutOver.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnCutOver.ImageAlign")));
			this.btnCutOver.ImageIndex = ((int)(resources.GetObject("btnCutOver.ImageIndex")));
			this.btnCutOver.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("btnCutOver.ImeMode")));
			this.btnCutOver.Location = ((System.Drawing.Point)(resources.GetObject("btnCutOver.Location")));
			this.btnCutOver.Name = "btnCutOver";
			this.btnCutOver.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("btnCutOver.RightToLeft")));
			this.btnCutOver.Size = ((System.Drawing.Size)(resources.GetObject("btnCutOver.Size")));
			this.btnCutOver.TabIndex = ((int)(resources.GetObject("btnCutOver.TabIndex")));
			this.btnCutOver.Text = resources.GetString("btnCutOver.Text");
			this.btnCutOver.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnCutOver.TextAlign")));
			this.btnCutOver.Visible = ((bool)(resources.GetObject("btnCutOver.Visible")));
			this.btnCutOver.Click += new System.EventHandler(this.btnCutOver_Click);
			// 
			// btnIgnore
			// 
			this.btnIgnore.AccessibleDescription = resources.GetString("btnIgnore.AccessibleDescription");
			this.btnIgnore.AccessibleName = resources.GetString("btnIgnore.AccessibleName");
			this.btnIgnore.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("btnIgnore.Anchor")));
			this.btnIgnore.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnIgnore.BackgroundImage")));
			this.btnIgnore.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("btnIgnore.Dock")));
			this.btnIgnore.Enabled = ((bool)(resources.GetObject("btnIgnore.Enabled")));
			this.btnIgnore.FlatStyle = ((System.Windows.Forms.FlatStyle)(resources.GetObject("btnIgnore.FlatStyle")));
			this.btnIgnore.Font = ((System.Drawing.Font)(resources.GetObject("btnIgnore.Font")));
			this.btnIgnore.Image = ((System.Drawing.Image)(resources.GetObject("btnIgnore.Image")));
			this.btnIgnore.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnIgnore.ImageAlign")));
			this.btnIgnore.ImageIndex = ((int)(resources.GetObject("btnIgnore.ImageIndex")));
			this.btnIgnore.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("btnIgnore.ImeMode")));
			this.btnIgnore.Location = ((System.Drawing.Point)(resources.GetObject("btnIgnore.Location")));
			this.btnIgnore.Name = "btnIgnore";
			this.btnIgnore.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("btnIgnore.RightToLeft")));
			this.btnIgnore.Size = ((System.Drawing.Size)(resources.GetObject("btnIgnore.Size")));
			this.btnIgnore.TabIndex = ((int)(resources.GetObject("btnIgnore.TabIndex")));
			this.btnIgnore.Text = resources.GetString("btnIgnore.Text");
			this.btnIgnore.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnIgnore.TextAlign")));
			this.btnIgnore.Visible = ((bool)(resources.GetObject("btnIgnore.Visible")));
			this.btnIgnore.Click += new System.EventHandler(this.btnIgnore_Click);
			// 
			// btnCalculateTime
			// 
			this.btnCalculateTime.AccessibleDescription = resources.GetString("btnCalculateTime.AccessibleDescription");
			this.btnCalculateTime.AccessibleName = resources.GetString("btnCalculateTime.AccessibleName");
			this.btnCalculateTime.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("btnCalculateTime.Anchor")));
			this.btnCalculateTime.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnCalculateTime.BackgroundImage")));
			this.btnCalculateTime.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("btnCalculateTime.Dock")));
			this.btnCalculateTime.Enabled = ((bool)(resources.GetObject("btnCalculateTime.Enabled")));
			this.btnCalculateTime.FlatStyle = ((System.Windows.Forms.FlatStyle)(resources.GetObject("btnCalculateTime.FlatStyle")));
			this.btnCalculateTime.Font = ((System.Drawing.Font)(resources.GetObject("btnCalculateTime.Font")));
			this.btnCalculateTime.Image = ((System.Drawing.Image)(resources.GetObject("btnCalculateTime.Image")));
			this.btnCalculateTime.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnCalculateTime.ImageAlign")));
			this.btnCalculateTime.ImageIndex = ((int)(resources.GetObject("btnCalculateTime.ImageIndex")));
			this.btnCalculateTime.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("btnCalculateTime.ImeMode")));
			this.btnCalculateTime.Location = ((System.Drawing.Point)(resources.GetObject("btnCalculateTime.Location")));
			this.btnCalculateTime.Name = "btnCalculateTime";
			this.btnCalculateTime.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("btnCalculateTime.RightToLeft")));
			this.btnCalculateTime.Size = ((System.Drawing.Size)(resources.GetObject("btnCalculateTime.Size")));
			this.btnCalculateTime.TabIndex = ((int)(resources.GetObject("btnCalculateTime.TabIndex")));
			this.btnCalculateTime.Text = resources.GetString("btnCalculateTime.Text");
			this.btnCalculateTime.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnCalculateTime.TextAlign")));
			this.btnCalculateTime.Visible = ((bool)(resources.GetObject("btnCalculateTime.Visible")));
			this.btnCalculateTime.Click += new System.EventHandler(this.btnCalculateTime_Click);
			// 
			// ManualProductionPlanning
			// 
			this.AccessibleDescription = resources.GetString("$this.AccessibleDescription");
			this.AccessibleName = resources.GetString("$this.AccessibleName");
			this.AutoScaleBaseSize = ((System.Drawing.Size)(resources.GetObject("$this.AutoScaleBaseSize")));
			this.AutoScroll = ((bool)(resources.GetObject("$this.AutoScroll")));
			this.AutoScrollMargin = ((System.Drawing.Size)(resources.GetObject("$this.AutoScrollMargin")));
			this.AutoScrollMinSize = ((System.Drawing.Size)(resources.GetObject("$this.AutoScrollMinSize")));
			this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
			this.CancelButton = this.btnClose;
			this.ClientSize = ((System.Drawing.Size)(resources.GetObject("$this.ClientSize")));
			this.Controls.Add(this.btnIgnore);
			this.Controls.Add(this.btnCutOver);
			this.Controls.Add(this.btnSearch);
			this.Controls.Add(this.btnGenerate);
			this.Controls.Add(this.btnSave);
			this.Controls.Add(this.btnClose);
			this.Controls.Add(this.btnHelp);
			this.Controls.Add(this.dgrdData);
			this.Controls.Add(this.txtProductionLine);
			this.Controls.Add(this.txtCycle);
			this.Controls.Add(this.lblProductionLine);
			this.Controls.Add(this.btnProductionLine);
			this.Controls.Add(this.cboCCN);
			this.Controls.Add(this.btnCycleSearch);
			this.Controls.Add(this.lblCycle);
			this.Controls.Add(this.lblCCN);
			this.Controls.Add(this.dtmDate);
			this.Controls.Add(this.btnCalculateTime);
			this.Enabled = ((bool)(resources.GetObject("$this.Enabled")));
			this.Font = ((System.Drawing.Font)(resources.GetObject("$this.Font")));
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("$this.ImeMode")));
			this.KeyPreview = true;
			this.Location = ((System.Drawing.Point)(resources.GetObject("$this.Location")));
			this.MaximumSize = ((System.Drawing.Size)(resources.GetObject("$this.MaximumSize")));
			this.MinimumSize = ((System.Drawing.Size)(resources.GetObject("$this.MinimumSize")));
			this.Name = "ManualProductionPlanning";
			this.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("$this.RightToLeft")));
			this.StartPosition = ((System.Windows.Forms.FormStartPosition)(resources.GetObject("$this.StartPosition")));
			this.Text = resources.GetString("$this.Text");
			this.Closing += new System.ComponentModel.CancelEventHandler(this.ManualProductionPlanning_Closing);
			this.Load += new System.EventHandler(this.ManualProductionPlanning_Load);
			((System.ComponentModel.ISupportInitialize)(this.cboCCN)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.dgrdData)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.dtmDate)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void ManualProductionPlanning_Load(object sender, EventArgs e)
		{		
			const string METHOD_NAME = THIS + ".ManualProductionPlanning_Load()";
			try
			{
				Security objSecurity = new Security();
				this.Name = THIS;
				if (objSecurity.SetRightForUserOnForm(this, SystemProperty.UserName) == 0)
				{
					this.Close();
					PCSMessageBox.Show(ErrorCode.MESSAGE_YOU_HAVE_NO_RIGHT_TO_VIEW, MessageBoxIcon.Warning);
					return;
				}
				

				//Load CCN and set default CCN
				UtilsBO boUtils = new UtilsBO();
				DataSet dstCCN = boUtils.ListCCN();
				cboCCN.DataSource = dstCCN.Tables[MST_CCNTable.TABLE_NAME];
				cboCCN.DisplayMember	= MST_CCNTable.CODE_FLD;
				cboCCN.ValueMember		= MST_CCNTable.CCNID_FLD;
				
				FormControlComponents.PutDataIntoC1ComboBox(cboCCN,dstCCN.Tables[MST_CCNTable.TABLE_NAME],MST_CCNTable.CODE_FLD,MST_CCNTable.CCNID_FLD,MST_CCNTable.TABLE_NAME);

				
				//get grid layout
				dtbGridLayOut = FormControlComponents.StoreGridLayout(dgrdData);

				if (SystemProperty.CCNID != 0)
				{
					cboCCN.SelectedValue = SystemProperty.CCNID;
				}


				//load data structure
				DCRegenerateBO boDCRegenerate = new DCRegenerateBO();
				dstData = boDCRegenerate.GetDCPResultData(0,0,true);
				dgrdData.DataSource = dstData.Tables[0];

				FormControlComponents.RestoreGridLayout(dgrdData, dtbGridLayOut);

				#region dungla: build ignore table schema
				dtbIgnoreList.Columns.Add(new DataColumn(PRO_ProductionLineTable.PRODUCTIONLINEID_FLD, typeof(int)));
				dtbIgnoreList.Columns.Add(new DataColumn(MST_WorkCenterTable.WORKCENTERID_FLD, typeof(int)));
				#endregion
			}
			catch (PCSException ex)
			{
				PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
				try
				{
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION);
				}
			}
			catch (Exception ex)
			{
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR);
				try
				{
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION);
				}
			}
		}

		private void btnClose_Click(object sender, EventArgs e)
		{
			this.Close();		
		}

		private void btnCycleSearch_Click(object sender, EventArgs e)
		{
			const string METHOD_NAME = THIS + ".btnCycle_Click()";
			try
			{
				DataRowView drwResult = null;
				// Hashtable htbCondition = new Hashtable();
				if (cboCCN.SelectedValue != null)
				{
					intCCNID = int.Parse(cboCCN.SelectedValue.ToString());
				}
				else
				{
					PCSMessageBox.Show(ErrorCode.MESSAGE_RGA_CCN, MessageBoxIcon.Warning);
					cboCCN.Focus();
					return;
				}
				Hashtable hshCondition = new Hashtable();
				hshCondition.Add(MST_CCNTable.CCNID_FLD, intCCNID);
				drwResult = FormControlComponents.OpenSearchForm(PRO_DCOptionMasterTable.TABLE_NAME,PRO_DCOptionMasterTable.CYCLE_FLD,txtCycle.Text,hshCondition, true);
				if (drwResult != null)
				{
					txtCycle.Text = drwResult[PRO_DCOptionMasterTable.CYCLE_FLD].ToString();
					txtCycle.Tag = drwResult[PRO_DCOptionMasterTable.DCOPTIONMASTERID_FLD].ToString();
				}
				else
				{
					txtCycle.Focus();
					txtCycle.SelectAll();
				}
			}
			catch (PCSException ex)
			{
				// Displays the error message if throwed from PCSException.
				PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
			catch (Exception ex)
			{
				// Displays the error message if throwed from system.
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}		
		}

		private void btnProductionLine_Click(object sender, EventArgs e)
		{
			const string METHOD_NAME = THIS + ".btnProductionLine_Click()";
			
			try
			{
				SelectProductionLine(METHOD_NAME, true);
			}
			catch (PCSException ex)
			{
				PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
				try
				{
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
			catch (Exception ex)
			{
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error);
				try
				{
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}		
		}

		private bool SelectProductionLine(string pstrMethodName, bool pblnAlwaysShowDialog)
		{
			UtilsBO boUtil = new UtilsBO();
			Hashtable htbCriteria = new Hashtable();				

			//Call OpenSearchForm for selecting Production Line
			DataRowView drwResult = FormControlComponents.OpenSearchForm(PRO_ProductionLineTable.TABLE_NAME, PRO_ProductionLineTable.CODE_FLD, txtProductionLine.Text.Trim(), htbCriteria, pblnAlwaysShowDialog);
			
			//If has Production Line matched searching condition, fill values to form's controls
			if(drwResult != null)
			{
				txtProductionLine.Text = drwResult[PRO_ProductionLineTable.CODE_FLD].ToString();
				txtProductionLine.Tag = drwResult[PRO_ProductionLineTable.PRODUCTIONLINEID_FLD];

				//Reset Modified status
				txtProductionLine.Modified = false;
			}
			else if(!pblnAlwaysShowDialog)
			{
				txtProductionLine.Focus();
				return false;
			}

			return true;
		}

		private void btnSearch_Click(object sender, EventArgs e)
		{		
			const string METHOD_NAME = THIS + ".btnSearch_Click()";
			
			try
			{
				int intDCOptionMasterID = Convert.ToInt32(txtCycle.Tag);
				if (intDCOptionMasterID <= 0)
				{
					PCSMessageBox.Show(ErrorCode.MANDATORY_INVALID,MessageBoxIcon.Exclamation);
					txtCycle.Focus();
					return;
				}
				int intProductionLineID = Convert.ToInt32(txtProductionLine.Tag);
				if (intProductionLineID <= 0)
				{
					PCSMessageBox.Show(ErrorCode.MANDATORY_INVALID,MessageBoxIcon.Exclamation);
					txtProductionLine.Focus();
					return;
				}

				dtbProductInfo = (new PRO_DCOptionMasterDS()).GetProductInfoTable(intProductionLineID);

				//load data
				DCRegenerateBO boDCRegenerate = new DCRegenerateBO();
				dstData = boDCRegenerate.GetDCPResultData(intProductionLineID,intDCOptionMasterID,false);
				dgrdData.DataSource = dstData.Tables[0];

				FormControlComponents.RestoreGridLayout(dgrdData, dtbGridLayOut);
				dgrdData.Splits[0].DisplayColumns[ITM_ProductTable.CODE_FLD].Button = true;
				dgrdData.Splits[0].DisplayColumns[ITM_ProductTable.DESCRIPTION_FLD].Button = true;
				dgrdData.Splits[0].DisplayColumns[PRO_ShiftTable.SHIFTDESC_FLD].Button = true;
				dgrdData.Splits[0].DisplayColumns[ITM_ProductTable.REVISION_FLD].Locked = true;

				dgrdData.Columns[PRO_DCPResultDetailTable.STARTTIME_FLD].Editor = dtmDate;
				dgrdData.Columns[PRO_DCPResultDetailTable.STARTTIME_FLD].NumberFormat = Constants.DATETIME_FORMAT_HOUR;
				dgrdData.Columns[PRO_DCPResultDetailTable.ENDTIME_FLD].Editor = dtmDate;
				dgrdData.Columns[PRO_DCPResultDetailTable.ENDTIME_FLD].NumberFormat = Constants.DATETIME_FORMAT_HOUR;
				dgrdData.Columns[PRO_DCPResultDetailTable.QUANTITY_FLD].NumberFormat = Constants.INTERGER_NUMBERFORMAT;

				dgrdData.AllowAddNew = true;
			}
			catch (PCSException ex)
			{
				PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
				try
				{
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
			catch (Exception ex)
			{
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error);
				try
				{
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}		
		}

		private void dgrdData_ButtonClick(object sender, ColEventArgs e)
		{
			const string METHOD_NAME = THIS + ".dgrdData_ButtonClick()";
			try
			{
				if ((e.Column.DataColumn.DataField == ITM_ProductTable.CODE_FLD) || (e.Column.DataColumn.DataField == ITM_ProductTable.DESCRIPTION_FLD))
				{
					Hashtable htbCriteria = new Hashtable();	
					htbCriteria.Add(ITM_ProductTable.PRODUCTIONLINEID_FLD,txtProductionLine.Tag);

					//Call OpenSearchForm for selecting product
					DataRowView drwResult;
					if (dgrdData.AddNewMode == AddNewModeEnum.AddNewCurrent)
					{
						drwResult = FormControlComponents.OpenSearchForm(ITM_ProductTable.TABLE_NAME, ITM_ProductTable.CODE_FLD, dgrdData[dgrdData.Row, ITM_ProductTable.CODE_FLD].ToString().Trim(), htbCriteria, true);
					}
					else
					{
						drwResult = FormControlComponents.OpenSearchForm(ITM_ProductTable.TABLE_NAME, ITM_ProductTable.CODE_FLD, dgrdData.Columns[ITM_ProductTable.CODE_FLD].Text.Trim(), htbCriteria, true);
					}
				
					if(drwResult != null)
					{
						FillItemData(drwResult,e.Column.DataColumn.DataField);
					}
				}
				else if (e.Column.DataColumn.DataField == PRO_ShiftTable.SHIFTDESC_FLD)
				{
					Hashtable htbCriteria = new Hashtable();	
					DataRowView drwResult;
					if (dgrdData.AddNewMode == AddNewModeEnum.AddNewCurrent)
					{
						drwResult = FormControlComponents.OpenSearchForm(PRO_ShiftTable.TABLE_NAME, PRO_ShiftTable.SHIFTDESC_FLD, dgrdData[dgrdData.Row, PRO_ShiftTable.SHIFTDESC_FLD].ToString().Trim(), htbCriteria, true);
					}
					else
					{
						drwResult = FormControlComponents.OpenSearchForm(PRO_ShiftTable.TABLE_NAME, PRO_ShiftTable.SHIFTDESC_FLD, dgrdData.Columns[PRO_ShiftTable.SHIFTDESC_FLD].Text.Trim(), htbCriteria, true);
					}
				
					if(drwResult != null)
					{
						FillShiftData(drwResult);
					}
				}
			}
			catch (PCSException ex)
			{
				throw new PCSException(ex.mCode, METHOD_NAME, ex);
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message, ex);
			}
		}

		private void FillItemData(DataRowView pdrowData, string pstrDataField)
		{			
			int i = dgrdData.Row;

			dgrdData.EditActive = true;
			dgrdData[i, ITM_ProductTable.PRODUCTID_FLD] = pdrowData[ITM_ProductTable.PRODUCTID_FLD].ToString();
			dgrdData[i, ITM_ProductTable.CODE_FLD] = pdrowData[ITM_ProductTable.CODE_FLD].ToString();
			dgrdData[i, ITM_ProductTable.DESCRIPTION_FLD] = pdrowData[ITM_ProductTable.DESCRIPTION_FLD].ToString();
			dgrdData[i, ITM_ProductTable.REVISION_FLD] = pdrowData[ITM_ProductTable.REVISION_FLD].ToString();
			//dgrdData[i, MST_UnitOfMeasureTable.CODE_FLD] = pdrowData[ITM_ProductTable.REVISION_FLD].ToString();

			dgrdData.Col = dgrdData.Splits[0].DisplayColumns.IndexOf(dgrdData.Splits[0].DisplayColumns[pstrDataField]);
			dgrdData.Focus();
		}

		private void FillShiftData(DataRowView pdrowData)
		{			
			int i = dgrdData.Row;

			dgrdData.EditActive = true;
			dgrdData[i,PRO_ShiftTable.SHIFTID_FLD] = Convert.ToInt32(pdrowData[PRO_ShiftTable.SHIFTID_FLD]);
			dgrdData[i,PRO_ShiftTable.SHIFTDESC_FLD] = pdrowData[PRO_ShiftTable.SHIFTDESC_FLD].ToString();

			dgrdData.Col = dgrdData.Splits[0].DisplayColumns.IndexOf(dgrdData.Splits[0].DisplayColumns[PRO_ShiftTable.SHIFTDESC_FLD]);
			dgrdData.Focus();
		}

		private void dgrdData_AfterColUpdate(object sender, ColEventArgs e)
		{
			const string METHOD_NAME = THIS + ".dgrdData_AfterColUpdate()";
			try
			{
				#region recalculate
				
				double dblVarLT =0;
				double dblMachineNo =0;
				try
				{
					dblVarLT = Convert.ToInt32(dtbProductInfo.Select("ProductID = " + dgrdData.Columns["ProductID"])[0]["LTVariableTime"]);
					dblMachineNo = Convert.ToInt32(dtbProductInfo.Select("ProductID = " + dgrdData.Columns["ProductID"])[0]["MachineNo"]);
				}catch{}
				double dblQuantity = 0;
				try
				{
					dblQuantity = Convert.ToDouble(dgrdData.Columns[PRO_DCPResultDetailTable.QUANTITY_FLD].Value);
				}catch{}

				if(e.Column.DataColumn.DataField == PRO_DCPResultDetailTable.STARTTIME_FLD)
				{
					// update DueDate: End Date Time = Start Date Time + (Quantity * Product.VariableLT/86400)
					if(dgrdData.Columns[PRO_DCPResultDetailTable.STARTTIME_FLD].Value != DBNull.Value)
					{
						dgrdData.Columns[PRO_DCPResultDetailTable.ENDTIME_FLD].Value =
							((DateTime)dgrdData.Columns[PRO_DCPResultDetailTable.STARTTIME_FLD].Value).AddSeconds(dblQuantity * dblVarLT/dblMachineNo);
					}
				}
				else if(e.Column.DataColumn.DataField == PRO_DCPResultDetailTable.ENDTIME_FLD)
				{
					// update StartDate: Start Date Time = End Date Time - (Quantity * Product.VariableLT/86400)
					if(dgrdData.Columns[PRO_DCPResultDetailTable.ENDTIME_FLD].Value != DBNull.Value)
					{
						dgrdData.Columns[PRO_DCPResultDetailTable.STARTTIME_FLD].Value =
							((DateTime)dgrdData.Columns[PRO_DCPResultDetailTable.ENDTIME_FLD].Value).AddSeconds(- dblQuantity * dblVarLT/dblMachineNo);
					}
				}
				else if(e.Column.DataColumn.DataField == PRO_DCPResultDetailTable.QUANTITY_FLD)
				{
					// update DueDate: End Date Time = Start Date Time + (Quantity * Product.VariableLT/86400)
					if(dgrdData.Columns[PRO_DCPResultDetailTable.STARTTIME_FLD].Value != DBNull.Value)
					{
						dgrdData.Columns[PRO_DCPResultDetailTable.ENDTIME_FLD].Value =
							((DateTime)dgrdData.Columns[PRO_DCPResultDetailTable.STARTTIME_FLD].Value).AddSeconds(dblQuantity * dblVarLT/dblMachineNo);
					}
				}
				if(dgrdData.Columns[PRO_DCPResultDetailTable.STARTTIME_FLD].Value != DBNull.Value)				
					dgrdData.Columns[PRO_DCPResultDetailTable.WORKINGDATE_FLD].Value = ((DateTime)dgrdData.Columns[PRO_DCPResultDetailTable.STARTTIME_FLD].Value).Date;
				#endregion
			}
			catch (PCSException ex)
			{
				// Displays the error message if throwed from PCSException.
				PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
			catch (Exception ex)
			{
				// Displays the error message if throwed from system.
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}

		}

		private void btnGenerate_Click(object sender, EventArgs e)
		{
			const string METHOD_NAME = THIS + ".btnGenerate_Click()";
			try
			{
				if(txtCycle.Text.Length == 0)
				{
					PCSMessageBox.Show(ErrorCode.MANDATORY_INVALID);
					txtCycle.Focus();
					return;
				}
				if(txtProductionLine.Text.Length == 0)
				{
					PCSMessageBox.Show(ErrorCode.MANDATORY_INVALID);
					txtProductionLine.Focus();
					return;
				}

				int intDCPOptionMasterID;//, intWorkCenterID, intProductionLineID;
				//DCRegenerateBO boDCRegenerate = new DCRegenerateBO();
				intDCPOptionMasterID = Convert.ToInt32(txtCycle.Tag);
				//intProductionLineID = Convert.ToInt32(txtProductionLine.Tag);
				//intWorkCenterID = boDCRegenerate.GetMainWorkCenterID(intProductionLineID);
				btnSearch_Click(null,null);

				//boDCRegenerate.RunMPPNew(intDCPOptionMasterID, intWorkCenterID, intProductionLineID,dstData, dtbIgnoreList, dtbBeginStock);
				//PCSMessageBox.Show(ErrorCode.MESSAGE_GENERATED_SUCCESSFULLY,MessageBoxIcon.Information,new string[]{"Manual DCP"});

				btnGenerate.Enabled = false;
				thrProcess = new Thread(new ThreadStart(ManualPP));
				thrProcess.Start();
				if (thrProcess.ThreadState == ThreadState.Stopped || !thrProcess.IsAlive)
					thrProcess.Abort();
			}
			catch (PCSException ex)
			{
				// Displays the error message if throwed from PCSException.
				PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
			catch (Exception ex)
			{
				// Displays the error message if throwed from system.
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
		}

		private void btnSave_Click(object sender, EventArgs e)
		{
			const string METHOD_NAME = THIS + ".btnSave_Click()";
			try
			{
				if(txtCycle.Text.Length == 0)
				{
					PCSMessageBox.Show(ErrorCode.MANDATORY_INVALID);
					txtCycle.Focus();
					return;
				}
				if(txtProductionLine.Text.Length == 0)
				{
					PCSMessageBox.Show(ErrorCode.MANDATORY_INVALID);
					txtProductionLine.Focus();
					return;
				}
				for(int i=0; i < dgrdData.RowCount; i++)
				{
					if(dgrdData[i, ITM_ProductTable.CODE_FLD] == DBNull.Value)
					{
						PCSMessageBox.Show(ErrorCode.MANDATORY_INVALID);
						dgrdData.Focus();
						dgrdData.Row = i;
						dgrdData.Col = dgrdData.Columns.IndexOf(dgrdData.Columns[ITM_ProductTable.CODE_FLD]);
						return;
					}
					if(dgrdData[i, PRO_DCPResultDetailTable.STARTTIME_FLD] == DBNull.Value)
					{
						PCSMessageBox.Show(ErrorCode.MANDATORY_INVALID);
						dgrdData.Focus();
						dgrdData.Row = i;
						dgrdData.Col = dgrdData.Columns.IndexOf(dgrdData.Columns[PRO_DCPResultDetailTable.STARTTIME_FLD]);
						return;
					}
					if(dgrdData[i, PRO_DCPResultDetailTable.ENDTIME_FLD] == DBNull.Value)
					{
						PCSMessageBox.Show(ErrorCode.MANDATORY_INVALID);
						dgrdData.Focus();
						dgrdData.Row = i;
						dgrdData.Col = dgrdData.Columns.IndexOf(dgrdData.Columns[PRO_DCPResultDetailTable.ENDTIME_FLD]);
						return;
					}
					if(dgrdData[i, PRO_DCPResultDetailTable.QUANTITY_FLD] == DBNull.Value)
					{
						PCSMessageBox.Show(ErrorCode.MANDATORY_INVALID);
						dgrdData.Focus();
						dgrdData.Row = i;
						dgrdData.Col = dgrdData.Columns.IndexOf(dgrdData.Columns[PRO_DCPResultDetailTable.QUANTITY_FLD]);
						return;
					}
					if(dgrdData[i, PRO_ShiftTable.SHIFTID_FLD] == DBNull.Value)
					{
						PCSMessageBox.Show(ErrorCode.MANDATORY_INVALID);
						dgrdData.Focus();
						dgrdData.Row = i;
						dgrdData.Col = dgrdData.Columns.IndexOf(dgrdData.Columns[PRO_ShiftTable.SHIFTID_FLD]);
						return;
					}
				}


				DCRegenerateBO boDCRegenerate = new DCRegenerateBO();
				int intDCPOptionMasterID, intWorkCenterID, intProductionLineID;
				intDCPOptionMasterID = Convert.ToInt32(txtCycle.Tag);
				intProductionLineID = Convert.ToInt32(txtProductionLine.Tag);
				intWorkCenterID = boDCRegenerate.GetMainWorkCenterID(intProductionLineID);
				boDCRegenerate.SaveManualProductionPlanning(intDCPOptionMasterID,intWorkCenterID,intProductionLineID,dstData.Tables[0] );
				PCSMessageBox.Show(ErrorCode.MESSAGE_AFTER_SAVE_DATA,MessageBoxIcon.Information);
				// refresh the grid
				btnSearch_Click(null, null);
			}
			catch (PCSException ex)
			{
				// Displays the error message if throwed from PCSException.
				PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
			catch (Exception ex)
			{
				// Displays the error message if throwed from system.
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
		}

		private void btnCutOver_Click(object sender, EventArgs e)
		{
			const string METHOD_NAME = THIS + ".btnCutOver_Click()";
			try
			{
				if(txtCycle.Text.Length == 0)
				{
					PCSMessageBox.Show(ErrorCode.MANDATORY_INVALID);
					txtCycle.Focus();
					return;
				}
				if(txtProductionLine.Text.Length == 0)
				{
					PCSMessageBox.Show(ErrorCode.MANDATORY_INVALID);
					txtProductionLine.Focus();
					return;
				}
				RoughCutCapacity frmRoughCut = new RoughCutCapacity(Convert.ToInt32(txtProductionLine.Tag), Convert.ToInt32(txtCycle.Tag));
				frmRoughCut.Show();
			}
			catch (PCSException ex)
			{
				// Displays the error message if throwed from PCSException.
				PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
			catch (Exception ex)
			{
				// Displays the error message if throwed from system.
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
		}
		/// <summary>
		/// txtCycle_Validating
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		/// <author>Trada</author>
		/// <date>Friday, September 29 2006</date>
		private void txtCycle_Validating(object sender, CancelEventArgs e)
		{
			const string METHOD_NAME = THIS + ".btnCycle_Click()";
			try
			{
				if (txtCycle.Text == string.Empty)
				{
					txtCycle.Tag = null;
					return;
				}
				if (!txtCycle.Modified) return;
				DataRowView drwResult = null;
				// Hashtable htbCondition = new Hashtable();
				if (cboCCN.SelectedValue != null)
				{
					intCCNID = int.Parse(cboCCN.SelectedValue.ToString());
				}
				else
				{
					PCSMessageBox.Show(ErrorCode.MESSAGE_RGA_CCN, MessageBoxIcon.Warning);
					cboCCN.Focus();
					return;
				}
				Hashtable hshCondition = new Hashtable();
				hshCondition.Add(MST_CCNTable.CCNID_FLD, intCCNID);
				drwResult = FormControlComponents.OpenSearchForm(PRO_DCOptionMasterTable.TABLE_NAME,PRO_DCOptionMasterTable.CYCLE_FLD,txtCycle.Text,hshCondition, false);
				if (drwResult != null)
				{
					txtCycle.Text = drwResult[PRO_DCOptionMasterTable.CYCLE_FLD].ToString();
					txtCycle.Tag = drwResult[PRO_DCOptionMasterTable.DCOPTIONMASTERID_FLD].ToString();
				}
				else
				{
					e.Cancel = true;
				}
			}
			catch (PCSException ex)
			{
				// Displays the error message if throwed from PCSException.
				PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
			catch (Exception ex)
			{
				// Displays the error message if throwed from system.
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
		}
		/// <summary>
		/// txtCycle_KeyDown
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		/// <author>Trada</author>
		/// <date>Friday, September 29 2006</date>
		private void txtCycle_KeyDown(object sender, KeyEventArgs e)
		{
			if (e.KeyCode == Keys.F4)
			{
				btnCycleSearch_Click(null, null);
			}
		}
		/// <summary>
		/// txtProductionLine_Validating
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		/// <author>Trada</author>
		/// <date>Friday, September 29 2006</date>
		private void txtProductionLine_Validating(object sender, CancelEventArgs e)
		{
			const string METHOD_NAME = THIS + ".txtProductionLine_Validating()";
			
			try
			{
				SelectProductionLine(METHOD_NAME, false);
			}
			catch (PCSException ex)
			{
				PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
				try
				{
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
			catch (Exception ex)
			{
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error);
				try
				{
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}		
		}
		/// <summary>
		/// txtProductionLine_KeyDown
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		/// <author>Trada</author>
		/// <date>Friday, September 29 2006</date>
		private void txtProductionLine_KeyDown(object sender, KeyEventArgs e)
		{
			if (e.KeyCode == Keys.F4)
			{
				btnProductionLine_Click(null, null);
			}
		}

		private void btnIgnore_Click(object sender, EventArgs e)
		{
			const string METHOD_NAME = THIS + ".btnIgnore_Click()";
			
			try
			{
				IgnoreProductionLine frmIgnore = new IgnoreProductionLine(dtbIgnoreList);
				frmIgnore.ShowDialog();
				dtbIgnoreList = frmIgnore.IgnoreList;
			}
			catch (PCSException ex)
			{
				PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
				try
				{
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
			catch (Exception ex)
			{
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error);
				try
				{
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
		}
		private void ManualPP()
		{
			const string METHOD_NAME = THIS + ".ManualPP()";
			try
			{
				Cursor = Cursors.WaitCursor;

				int intDCPOptionMasterID, intWorkCenterID, intProductionLineID;
				DCRegenerateBO boDCRegenerate = new DCRegenerateBO();
				intDCPOptionMasterID = Convert.ToInt32(txtCycle.Tag);
				intProductionLineID = Convert.ToInt32(txtProductionLine.Tag);
				intWorkCenterID = boDCRegenerate.GetMainWorkCenterID(intProductionLineID);

				#region dungla: calculate begin quantity first

				DateTime dtmServerDate = new UtilsBO().GetDBDate();
				dtbBeginStock.Clear();
				dtbBeginStock = CalculateBeginQuantity(intDCPOptionMasterID, cboCCN.SelectedValue.ToString(), dtmServerDate, dtbIgnoreList);

				#endregion

				//btnSearch_Click(null,null);
				boDCRegenerate.RunMPPNew(intDCPOptionMasterID, intWorkCenterID, intProductionLineID,dstData, dtbIgnoreList, dtbBeginStock);
				PCSMessageBox.Show(ErrorCode.MESSAGE_GENERATED_SUCCESSFULLY,MessageBoxIcon.Information,new string[]{"Manual DCP"});
				btnGenerate.Enabled = true;
				Cursor = Cursors.Default;
			}
			catch (ThreadAbortException ex)
			{
				Logger.LogMessage(ex.Message, METHOD_NAME, Level.DEBUG);
			}
			catch (PCSException ex)
			{
				PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
				try
				{
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION);
				}
			}
			catch (Exception ex)
			{
				string[] strMsg = new string[]{this.Text};
				PCSMessageBox.Show(ErrorCode.MESSAGE_CANNOT_ROLL_UP, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, strMsg);
				try
				{
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION);
				}
			}
			finally
			{
				Cursor = Cursors.Default;
				btnGenerate.Enabled = true;
			}
		}

		private void ManualProductionPlanning_Closing(object sender, CancelEventArgs e)
		{
			const string METHOD_NAME = THIS + ".ManualProductionPlanning_Closing()";
			try
			{
				// ask user to stop the thread
				if (thrProcess != null)
				{
					if (thrProcess.IsAlive || thrProcess.ThreadState == ThreadState.Running)
					{
						string[] strMsg = {this.Text};					
						DialogResult dlgResult = PCSMessageBox.Show(ErrorCode.MESSAGE_PROCESS_IS_RUNNING, MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, strMsg);
						switch (dlgResult)
						{
							case DialogResult.OK:
								// try to stop the thread
								try
								{
									thrProcess.Abort();
								}
								catch
								{
									e.Cancel = false;
								}
								break;
							case DialogResult.Cancel:
								e.Cancel = true;
								break;
						}
					}
				}
			}
			catch (ThreadAbortException ex)
			{
				Logger.LogMessage(ex.Message, METHOD_NAME, Level.DEBUG);
			}
			catch (PCSException ex)
			{
				// displays the error message.
				PCSMessageBox.Show(ex.mCode, MessageBoxButtons.OK, MessageBoxIcon.Error);
				// log message.
				try
				{
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
				}
			}
			catch (Exception ex)
			{
				// displays the error message.
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error);
				// log message.
				try
				{
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
				}
			}
		}

		private void dgrdData_KeyDown(object sender, KeyEventArgs e)
		{
			const string METHOD_NAME = THIS + ".dgrdData_KeyDown()";
			try
			{
				switch (e.KeyCode)
				{
					case Keys.Delete:
						if ((e.KeyCode == Keys.Delete)&&(dgrdData.SelectedRows.Count > 0))
						{
							if (btnSave.Enabled)
							{
								dgrdData.AllowDelete = true;
								FormControlComponents.DeleteMultiRowsOnTrueDBGrid(dgrdData);
							}
						}
						break;
				}
			}
			catch (PCSException ex)
			{
				PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
				try
				{
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION);
				}
			}
			catch (Exception ex)
			{
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR);
				try
				{
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION);
				}
			}
		}
		/// <summary>
		/// Calculate begin quantity for all item in seleted production line
		/// </summary>
		/// <param name="voCycle"></param>
		/// <param name="pstrCCNID"></param>
		/// <param name="dtmServerDate"></param>
		/// <param name="pdtbIgnoreList"></param>
		private DataTable CalculateBeginQuantity(int pintCycleID, string pstrCCNID, DateTime dtmServerDate, DataTable pdtbIgnoreList)
		{
			DCPReportBO boReport = new DCPReportBO();

			PRO_DCOptionMasterVO voCycle = (PRO_DCOptionMasterVO)boReport.GetCyclerMasterObject(pintCycleID);
			
			DataTable dtbBeginStock = boReport.GetBeginData(pintCycleID);
			// get planning offset
			DataTable dtbPlanningOffset = boReport.GetPlanningOffset(pstrCCNID);
			// get list of production line
			DataTable dtbListProductionLine = boReport.ListProductionLine();
			StringBuilder sbListLine = new StringBuilder();
			foreach (DataRow drowLine in dtbListProductionLine.Rows)
			{
				// check ignore list
				if (pdtbIgnoreList.Select("ProductionLineID = " + drowLine["ProductionLineID"].ToString()).Length == 0)
					sbListLine.Append(drowLine["ProductionLineID"].ToString()).Append(",");
			}
			sbListLine.Append("0");
			// get list of all product
			DataTable dtbListProduct = boReport.ListProduct(pstrCCNID, sbListLine.ToString());
			// cache quantity
			DataTable dtbCache = boReport.GetBeginNetQuantity(pstrCCNID);
			// delivery for parent
			DataTable dtbDeliveryForParent = boReport.GetDeliveryForParent(pstrCCNID);
			// delivery for SO
			DataTable dtbDeliveryForSO = boReport.GetDeliveryForSO();
			// produce from work order
			DataTable dtbProduce = boReport.GetTotalWO(pstrCCNID);
			// working time
			DataTable dtbWorkingTime = boReport.GetWorkingTime();
			// calculate foreach product
			foreach (DataRow drowProduct in dtbListProduct.Rows)
			{
				string strProductID = drowProduct["ProductID"].ToString();
				string strProductionLineID = drowProduct["ProductionLineID"].ToString();
				
				// refine cycle
				voCycle = RefineCycle(strProductionLineID, dtbPlanningOffset, voCycle);
				// only update for effect month by planning period
				string strFilter = "ProductID = " + strProductID
					+ " AND DCOptionMasterID = " + voCycle.DCOptionMasterID;
				decimal decScrapPercent = Convert.ToDecimal(drowProduct[ITM_ProductTable.SCRAPPERCENT_FLD]);
				// check if product already has data in database, need update
				if (dtbBeginStock.Select(strFilter).Length > 0)
				{
					DataRow drowProductStock = dtbBeginStock.Select(strFilter)[0];
					CalculateQuantity(voCycle, voCycle.PlanningPeriod.Date, dtmServerDate, strProductID, dtbCache,
						ref drowProductStock, dtbProduce, dtbDeliveryForSO,
						dtbDeliveryForParent, dtbWorkingTime, decScrapPercent);
				}
				else // else add new record
				{
					DataRow drowProductStock = dtbBeginStock.NewRow();
					drowProductStock["ProductID"] = strProductID;
					CalculateQuantity(voCycle, voCycle.PlanningPeriod.Date, dtmServerDate, strProductID, dtbCache,
						ref drowProductStock, dtbProduce, dtbDeliveryForSO,
						dtbDeliveryForParent, dtbWorkingTime, decScrapPercent);
					dtbBeginStock.Rows.Add(drowProductStock);
				}
			}
			return dtbBeginStock;
		}
		private DataRow CalculateQuantity(PRO_DCOptionMasterVO voCycle, DateTime dtmEffectDate, DateTime dtmServerDate,
			string strProductID, DataTable dtbCache, ref DataRow drowProductStock, DataTable dtbProduce,
			DataTable dtbDeliveryForSO, DataTable dtbDeliveryForParent, DataTable dtbWorkingTime, decimal pdecScrapPercent)
		{
			decimal decQuantity = 0, decCacheQuantity = 0;

			drowProductStock[PRO_DCOptionMasterTable.DCOPTIONMASTERID_FLD] = voCycle.DCOptionMasterID;

			#region quantity from cache

			string strFilter = "ProductID = " + strProductID;
			try
			{
				decCacheQuantity = Convert.ToDecimal(dtbCache.Compute("SUM(Quantity)", strFilter));
			}
			catch{}

			#endregion

			// use cache as begin quantity
			if (voCycle.UseCacheAsBegin)
				drowProductStock["Quantity"] = decCacheQuantity;
			else
			{
				#region Delivery for parent and produce

				decimal decDeliveryForParent = 0, decProduce = 0;
				DateTime dtmStartTime = dtmEffectDate;
				DateTime dtmEndTime = dtmEffectDate;
				GetStartAndEndTime(dtmEffectDate, ref dtmStartTime, ref dtmEndTime, dtbWorkingTime);
				string strFilterForParent = "ProductID = '" + strProductID + "' AND"
					+ " StartDate >='" + dtmServerDate.ToString() + "' AND"
					+ " StartDate <'" + dtmStartTime.ToString() + "'";
				try
				{
					decDeliveryForParent += Convert.ToDecimal(dtbDeliveryForParent.Compute("SUM(Quantity)", strFilterForParent));
				}
				catch{}

				#region produce

				string strFilterProduce = "ProductID = '" + strProductID + "' AND"
					+ " DueDate >='" + dtmServerDate.ToString() + "' AND"
					+ " DueDate <'" + dtmStartTime.ToString() + "'";
				try
				{
					decProduce += Convert.ToDecimal(dtbProduce.Compute("SUM(Quantity)", strFilterProduce));
				}
				catch{}

				#endregion

				#endregion
					
				#region Delivery for SO
					
				decimal decDeliveryForSO = 0;
				DateTime dtmStartTimeSO = dtmEffectDate;
				DateTime dtmEndTimeSO = dtmEffectDate;
				GetStartAndEndTime(dtmEffectDate, ref dtmStartTimeSO, ref dtmEndTimeSO, dtbWorkingTime);
				string strFilterSO = "ProductID = " + strProductID + " AND"
					+ " ScheduleDate >='" + dtmServerDate.ToString() + "' AND"
					+ " ScheduleDate <'" + dtmStartTimeSO.ToString() + "'";
				try
				{
					decDeliveryForSO += Convert.ToDecimal(dtbDeliveryForSO.Compute("SUM(Quantity)", strFilterSO));
				}
				catch{}
					
				#endregion 

				// quantity = cache + produce - delivery (so + parent)
				decQuantity = decCacheQuantity + decProduce - (decDeliveryForParent + decDeliveryForSO);

				decQuantity = (decQuantity < 0) ? 0 : decQuantity;
				drowProductStock["Quantity"] = decQuantity * (1 - pdecScrapPercent / 100);
			}

			return drowProductStock;
		}
		private PRO_DCOptionMasterVO RefineCycle(string pstrProductionLineID, DataTable pdtbPlanningOffset, PRO_DCOptionMasterVO voCycle)
		{
			string strFilter = "DCOptionMasterID = " + voCycle.DCOptionMasterID + " AND ProductionLineID = " +
				pstrProductionLineID;
			DataRow[] drowOffset = pdtbPlanningOffset.Select(strFilter);
			// refine as of date of the cycle based on planning offset of current production line
			if (drowOffset.Length > 0)
			{
				if (drowOffset[0]["PlanningStartDate"] != null && drowOffset[0]["PlanningStartDate"] != DBNull.Value)
				{
					DateTime dtmStartDate = (DateTime) drowOffset[0]["PlanningStartDate"];
					voCycle.AsOfDate = new DateTime(dtmStartDate.Year, dtmStartDate.Month, dtmStartDate.Day);
				}
			}
			return voCycle;
		}
		private void GetStartAndEndTime(DateTime pdtmCurrentDay, ref DateTime pdtmStartTime,
			ref DateTime pdtmEndTime, DataTable pdtmWorkingTime)
		{
			DataRow[] drowShifts = pdtmWorkingTime.Select(string.Empty, "WorkTimeFrom ASC");

			if (drowShifts.Length <= 0)
				return;
			//change shift configured day to working day
			pdtmStartTime = new DateTime(pdtmCurrentDay.Year, pdtmCurrentDay.Month, pdtmCurrentDay.Day,
				((DateTime)drowShifts[0]["WorkTimeFrom"]).Hour,
				((DateTime)drowShifts[0]["WorkTimeFrom"]).Minute,
				((DateTime)drowShifts[0]["WorkTimeFrom"]).Second);
			pdtmEndTime = new DateTime(pdtmCurrentDay.Year, pdtmCurrentDay.Month, pdtmCurrentDay.Day,
				((DateTime)drowShifts[drowShifts.Length - 1]["WorkTimeTo"]).Hour,
				((DateTime)drowShifts[drowShifts.Length - 1]["WorkTimeTo"]).Minute,
				((DateTime)drowShifts[drowShifts.Length - 1]["WorkTimeTo"]).Second);
			double dblDiff = ((DateTime)drowShifts[drowShifts.Length - 1]["WorkTimeTo"]).
				Subtract((DateTime)drowShifts[0]["WorkTimeFrom"]).Days;
			pdtmEndTime = pdtmEndTime.AddDays(dblDiff);
		}

		private void btnCalculateTime_Click(object sender, System.EventArgs e)
		{
			const string METHOD_NAME = THIS + ".btnCalculateTime_Click()";
			try
			{
				int intDCOptionMasterID = Convert.ToInt32(txtCycle.Tag);
				if (intDCOptionMasterID <= 0)
				{
					PCSMessageBox.Show(ErrorCode.MANDATORY_INVALID,MessageBoxIcon.Exclamation);
					txtCycle.Focus();
					return;
				}
				int intProductionLineID = Convert.ToInt32(txtProductionLine.Tag);
				if (intProductionLineID <= 0)
				{
					PCSMessageBox.Show(ErrorCode.MANDATORY_INVALID,MessageBoxIcon.Exclamation);
					txtProductionLine.Focus();
					return;
				}
				if (dstData == null || dstData.Tables.Count == 0 || dstData.Tables[0].Rows.Count == 0)
					return;
				this.Cursor = Cursors.WaitCursor;
				DCOptionsBO boOption = new DCOptionsBO();
				DataRow drowCycle = boOption.GetDCOptionMaster(intDCOptionMasterID);
				DateTime dtmFromDate = Convert.ToDateTime(drowCycle[PRO_DCOptionMasterTable.ASOFDATE_FLD]);
				DateTime dtmToDate = dtmFromDate.AddDays(Convert.ToDouble(drowCycle[PRO_DCOptionMasterTable.PLANHORIZON_FLD]));
				DataSet dstTemp = dstData.Copy();
				dstTemp.Tables[0].Columns.Add("Seq", typeof(int));
				DataTable dtbProductSequence = boOption.GetProductSequence(intProductionLineID).Tables[0];
				DataTable dtbShift = boOption.ListShift();
				foreach (DataRow drowTemp in dstTemp.Tables[0].Rows)
				{
					string strProductID = drowTemp[ITM_ProductTable.PRODUCTID_FLD].ToString();
					int intSequence = 0;
					try
					{
						intSequence = Convert.ToInt32(dtbProductSequence.Select(ITM_ProductTable.PRODUCTID_FLD + "=" + strProductID)[0]["Seq"]);
					}
					catch{}
					drowTemp["Seq"] = intSequence;
				}
				DCPReportBO boReport = new DCPReportBO();
				DataTable dtbWorkingTime = boReport.GetWorkingTime(intProductionLineID);
				for (DateTime dtmDay = dtmFromDate; dtmDay <= dtmToDate; dtmDay = dtmDay.AddDays(1))
				{
					string strFilter = "WorkingDate = '" + dtmDay.ToString("G") + "'";
					DataRow[] drowDays = dstTemp.Tables[0].Select(strFilter, "Seq ASC, ProductID ASC");
					DateTime dtmStartDay = dtmDay;
					DateTime dtmEndDay = dtmDay;
					GetStartAndEndTime(dtmDay, ref dtmStartDay, ref dtmEndDay, dtbWorkingTime);
					DateTime dtmEndTime = dtmStartDay;
					for (int i = 0; i < drowDays.Length; i++)
					{
						DataRow drowData = drowDays[i];
						DateTime dtmStartTime = dtmEndTime;
						string strItem = drowData[ITM_ProductTable.PRODUCTID_FLD].ToString();

						int intShiftID = 0;
						
						double dblVarLT =0;
						double dblMachineNo =0;
						try
						{
							dblVarLT = Convert.ToInt32(dtbProductInfo.Select("ProductID = " + strItem)[0]["LTVariableTime"]);
							dblMachineNo = Convert.ToInt32(dtbProductInfo.Select("ProductID = " + strItem)[0]["MachineNo"]);
						}
						catch{}
						double dblQuantity = 0;
						try
						{
							dblQuantity = Convert.ToDouble(drowData[PRO_DCPResultDetailTable.QUANTITY_FLD]);
						}
						catch{}

						double dblTotalTime = dblQuantity * dblVarLT/dblMachineNo;

						dtmEndTime = CalculateEndTime(dtmStartTime, dblTotalTime, dtbWorkingTime, ref intShiftID, dtmDay);
						
						drowData[PRO_DCPResultDetailTable.STARTTIME_FLD] = dtmStartTime;
						drowData[PRO_DCPResultDetailTable.ENDTIME_FLD] = dtmEndTime;
						drowData[PRO_DCPResultDetailTable.SHIFTID_FLD] = intShiftID;
						drowData[PRO_ShiftTable.SHIFTDESC_FLD] = dtbShift.Select(PRO_ShiftTable.SHIFTID_FLD + "=" + intShiftID)[0][PRO_ShiftTable.SHIFTDESC_FLD];
					}
				}
				dstData = dstTemp;
				dgrdData.DataSource = dstData.Tables[0];
				FormControlComponents.RestoreGridLayout(dgrdData, dtbGridLayOut);
				dgrdData.Splits[0].DisplayColumns[ITM_ProductTable.CODE_FLD].Button = true;
				dgrdData.Splits[0].DisplayColumns[ITM_ProductTable.DESCRIPTION_FLD].Button = true;
				dgrdData.Splits[0].DisplayColumns[PRO_ShiftTable.SHIFTDESC_FLD].Button = true;
				dgrdData.Splits[0].DisplayColumns[ITM_ProductTable.REVISION_FLD].Locked = true;

				dgrdData.Columns[PRO_DCPResultDetailTable.STARTTIME_FLD].Editor = dtmDate;
				dgrdData.Columns[PRO_DCPResultDetailTable.STARTTIME_FLD].NumberFormat = Constants.DATETIME_FORMAT_HOUR;
				dgrdData.Columns[PRO_DCPResultDetailTable.ENDTIME_FLD].Editor = dtmDate;
				dgrdData.Columns[PRO_DCPResultDetailTable.ENDTIME_FLD].NumberFormat = Constants.DATETIME_FORMAT_HOUR;
				dgrdData.Columns[PRO_DCPResultDetailTable.QUANTITY_FLD].NumberFormat = Constants.INTERGER_NUMBERFORMAT;
//				DCRegenerateBO boDCRegenerate = new DCRegenerateBO();
//				int intWorkCenterID;
//				intProductionLineID = Convert.ToInt32(txtProductionLine.Tag);
//				intWorkCenterID = Convert.ToInt32(dtbWorkingTime.Rows[0][MST_WorkCenterTable.WORKCENTERID_FLD]);
//				boDCRegenerate.SaveManualProductionPlanning(intDCOptionMasterID,intWorkCenterID,intProductionLineID,dstTemp.Tables[0] );
//				PCSMessageBox.Show(ErrorCode.MESSAGE_AFTER_SAVE_DATA,MessageBoxIcon.Information);
				// refresh the grid
//				btnSearch_Click(null, null);
			}
			catch (PCSException ex)
			{
				PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
				try
				{
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
			catch (Exception ex)
			{
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error);
				try
				{
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
			finally
			{
				this.Cursor = Cursors.Default;
			}
		}
		private DateTime CalculateEndTime(DateTime pdtmStartTime, double pdblTotalTime, DataTable pdtbWorkingTime, ref int pintShiftID, DateTime pdtmDay)
		{
			DataRow[] arrShifts = pdtbWorkingTime.Select(PRO_WCCapacityTable.BEGINDATE_FLD + " <= '" + pdtmDay.Date + "' AND " + PRO_WCCapacityTable.ENDDATE_FLD + " >= '" + pdtmDay.Date + "'",PRO_ShiftPatternTable.WORKTIMEFROM_FLD + " ASC");
			ArrayList arrTimeMarks = new ArrayList();

			if (arrShifts.Length == 0)
				return DateTime.MinValue;
			foreach (DataRow drowShift in arrShifts)
			{
				int intShiftID = Convert.ToInt32(drowShift[PRO_ShiftPatternTable.SHIFTID_FLD]);
				DateTime dtmWorkTimeFrom = Convert.ToDateTime(drowShift[PRO_ShiftPatternTable.WORKTIMEFROM_FLD]);
				DateTime dtmWorkTimeTo = Convert.ToDateTime(drowShift[PRO_ShiftPatternTable.WORKTIMETO_FLD]);
				arrTimeMarks.Add(new TimeMark(dtmWorkTimeFrom,1,intShiftID,false));
				arrTimeMarks.Add(new TimeMark(dtmWorkTimeTo,-1,intShiftID,true));
				try
				{
					DateTime dtmRefreshingFrom = Convert.ToDateTime(drowShift[PRO_ShiftPatternTable.REFRESHINGFROM_FLD]);
					DateTime dtmRefreshingTo = Convert.ToDateTime(drowShift[PRO_ShiftPatternTable.REFRESHINGTO_FLD]);
					arrTimeMarks.Add(new TimeMark(dtmRefreshingFrom,-1,intShiftID,false));
					arrTimeMarks.Add(new TimeMark(dtmRefreshingTo,1,intShiftID,false));
				}
				catch {}
				try
				{
					DateTime dtmRegularStopFrom = Convert.ToDateTime(drowShift[PRO_ShiftPatternTable.REGULARSTOPFROM_FLD]);
					DateTime dtmRegularStopTo = Convert.ToDateTime(drowShift[PRO_ShiftPatternTable.REGULARSTOPTO_FLD]);
					arrTimeMarks.Add(new TimeMark(dtmRegularStopFrom,-1,intShiftID,false));
					arrTimeMarks.Add(new TimeMark(dtmRegularStopTo,1,intShiftID,false));
				}
				catch {}
				try
				{
					DateTime dtmExtraStopFrom = Convert.ToDateTime(drowShift[PRO_ShiftPatternTable.EXTRASTOPFROM_FLD]);
					DateTime dtmExtraStopTo = Convert.ToDateTime(drowShift[PRO_ShiftPatternTable.EXTRASTOPTO_FLD]);
					arrTimeMarks.Add(new TimeMark(dtmExtraStopFrom,-1,intShiftID,false));
					arrTimeMarks.Add(new TimeMark(dtmExtraStopTo,1,intShiftID,false));
				}
				catch {}
			}
			arrTimeMarks.Sort(new TimeMarkComparer());

			double dblObtainedTime = 0;
			bool blnNote = false;
			DateTime dtmCheckPoint = pdtmStartTime.AddDays(-pdtmStartTime.Date.Subtract(Convert.ToDateTime(arrShifts[0][PRO_ShiftPatternTable.WORKTIMEFROM_FLD]).Date).Days);
			if (dtmCheckPoint < Convert.ToDateTime(arrShifts[0][PRO_ShiftPatternTable.WORKTIMEFROM_FLD])) 
			{
				dtmCheckPoint = dtmCheckPoint.AddDays(1);
				blnNote = true;
			}
			foreach (TimeMark objTimeMark in arrTimeMarks)
			{
				if ((objTimeMark.m_dtmTime < dtmCheckPoint) || ((objTimeMark.m_dtmTime == dtmCheckPoint) && (objTimeMark.m_blnEndOfShift)))
				{
					continue;
				}
				if (objTimeMark.m_shtFlag == -1)
				{
					dblObtainedTime += objTimeMark.m_dtmTime.Subtract(dtmCheckPoint).TotalSeconds;
					dtmCheckPoint = objTimeMark.m_dtmTime;
				}
				else if (objTimeMark.m_shtFlag == 1)
				{
					dtmCheckPoint = objTimeMark.m_dtmTime;
				}
				else
				{
					//Error, never occurs
				}
				if (dblObtainedTime >= pdblTotalTime)
				{
					pintShiftID = objTimeMark.m_intShiftID;
					return dtmCheckPoint.AddSeconds(pdblTotalTime - dblObtainedTime).AddDays(pdtmStartTime.Date.Subtract(Convert.ToDateTime(arrShifts[0][PRO_ShiftPatternTable.WORKTIMEFROM_FLD]).Date).Days);
				}
				else if (objTimeMark.m_blnEndOfShift)
				{
					pintShiftID = objTimeMark.m_intShiftID;
					return dtmCheckPoint.AddDays(pdtmStartTime.Date.Subtract(Convert.ToDateTime(arrShifts[0][PRO_ShiftPatternTable.WORKTIMEFROM_FLD]).Date).Days);
				}		
			}
			DateTime dtmReturn = dtmCheckPoint.AddSeconds(pdblTotalTime - dblObtainedTime).AddDays(pdtmStartTime.Date.Subtract(Convert.ToDateTime(arrShifts[0][PRO_ShiftPatternTable.WORKTIMEFROM_FLD]).Date).Days);
			if (blnNote)
			{
				dtmReturn = dtmReturn.AddDays(-1);
			}
			return dtmReturn;
		}
		private class TimeMark
		{
			public TimeMark(DateTime pdtmTime, short pshtFlag,int pintShiftID,bool p_blnEndOfShift)
			{
				m_dtmTime = pdtmTime;
				m_shtFlag = pshtFlag;
				m_intShiftID = pintShiftID;
				m_blnEndOfShift = p_blnEndOfShift;
			}
			public DateTime m_dtmTime;
			public short m_shtFlag;
			public int m_intShiftID;
			public bool m_blnEndOfShift;
		}

		private class TimeMarkComparer : IComparer
		{
			public int Compare(object x, object y)
			{
				if (((TimeMark)x).m_dtmTime > ((TimeMark)y).m_dtmTime) 
				{
					return 1;
				}
				else if (((TimeMark)x).m_dtmTime < ((TimeMark)y).m_dtmTime) 
				{
					return -1;
				}
				else
				{
					if (((TimeMark)x).m_shtFlag > ((TimeMark)y).m_shtFlag)
					{
						return 1;
					}
					else if (((TimeMark)x).m_shtFlag < ((TimeMark)y).m_shtFlag)
					{
						return -1;
					}
					else
					{
						return 0;
					}
				}
			}
		}
	}
}
